Fix pagination bug for like and comment events

This commit is contained in:
Daniel Supernault 2018-06-03 21:04:01 -06:00
parent dfe451db70
commit 4751832ad3
8 changed files with 16 additions and 11 deletions

View file

@ -24,9 +24,9 @@ class ApiController extends Controller
$likes = Like::whereProfileId($profile->id) $likes = Like::whereProfileId($profile->id)
->orderBy('id', 'desc') ->orderBy('id', 'desc')
->take(100) ->take(1000)
->pluck('status_id'); ->pluck('status_id');
return response()->json($likes); return response()->json($likes);
} }
} }

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
!function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=1)}({1:function(e,n,t){e.exports=t("uOOV")},uOOV:function(e,n){$(document).ready(function(){$(".pagination").hide();var e=document.querySelector(".timeline-feed");new InfiniteScroll(e,{path:".pagination__next",append:".timeline-feed",history:!1})})}}); !function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/",t(t.s=1)}({1:function(e,n,t){e.exports=t("uOOV")},uOOV:function(e,n){$(document).ready(function(){$(".pagination").hide();var e=document.querySelector(".timeline-feed");new InfiniteScroll(e,{path:".pagination__next",append:".timeline-feed",history:!1}).on("append",function(e,n,t){pixelfed.hydrateLikes()})})}});

View file

@ -1,5 +1,5 @@
{ {
"/js/app.js": "/js/app.js?id=478eacc17a0ea6fba319", "/js/app.js": "/js/app.js?id=2c6c809a71f43c33dd4b",
"/css/app.css": "/css/app.css?id=ede5557443f098707138", "/css/app.css": "/css/app.css?id=ede5557443f098707138",
"/js/timeline.js": "/js/timeline.js?id=fcc86a9419b33a821c23" "/js/timeline.js": "/js/timeline.js?id=1ade82addcc153e4ff66"
} }

View file

@ -9,6 +9,7 @@ window.Popper = require('popper.js').default;
*/ */
try { try {
window.pixelfed = {};
window.$ = window.jQuery = require('jquery'); window.$ = window.jQuery = require('jquery');
require('bootstrap'); require('bootstrap');
window.InfiniteScroll = require('infinite-scroll'); window.InfiniteScroll = require('infinite-scroll');

View file

@ -5,7 +5,7 @@ $(document).ready(function() {
el.focus(); el.focus();
}); });
$('.comment-form').submit(function(e, data) { $(document).on('submit', '.comment-form', function(e, data) {
e.preventDefault(); e.preventDefault();
let el = $(this); let el = $(this);

View file

@ -11,9 +11,8 @@ $(document).ready(function() {
}) })
} }
hydrateLikes();
function hydrateLikes() { pixelfed.hydrateLikes = function() {
var likes = ls.get('likes'); var likes = ls.get('likes');
$('.like-form').each(function(i, el) { $('.like-form').each(function(i, el) {
var el = $(el); var el = $(el);
@ -24,9 +23,11 @@ $(document).ready(function() {
heart.addClass('fas fa-heart').removeClass('far fa-heart'); heart.addClass('fas fa-heart').removeClass('far fa-heart');
} }
}); });
} };
$('.like-form').submit(function(e) { pixelfed.hydrateLikes();
$(document).on('submit', '.like-form', function(e) {
e.preventDefault(); e.preventDefault();
var el = $(this); var el = $(this);
var id = el.data('id'); var id = el.data('id');

View file

@ -6,4 +6,7 @@ $(document).ready(function() {
append: '.timeline-feed', append: '.timeline-feed',
history: false, history: false,
}); });
infScroll.on( 'append', function( response, path, items ) {
pixelfed.hydrateLikes();
});
}); });