From 4751832ad3742e55d5e5e77e853c9c14b176ebcd Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 3 Jun 2018 21:04:01 -0600 Subject: [PATCH] Fix pagination bug for like and comment events --- app/Http/Controllers/ApiController.php | 4 ++-- public/js/app.js | Bin 1106850 -> 1106953 bytes public/js/timeline.js | Bin 709 -> 763 bytes public/mix-manifest.json | Bin 184 -> 184 bytes resources/assets/js/bootstrap.js | 1 + resources/assets/js/components/commentform.js | 2 +- resources/assets/js/components/likebutton.js | 9 +++++---- resources/assets/js/timeline.js | 3 +++ 8 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index 1b52e28f2..a596346bc 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -24,9 +24,9 @@ class ApiController extends Controller $likes = Like::whereProfileId($profile->id) ->orderBy('id', 'desc') - ->take(100) + ->take(1000) ->pluck('status_id'); - + return response()->json($likes); } } diff --git a/public/js/app.js b/public/js/app.js index 4160ff4b104f01d458155bd758caa0c9df814005..a7820a8a8c91a840606702bd7c8e98965de8ff91 100644 GIT binary patch delta 304 zcmZ2<+`03FbHf(K+24&)@{>z*Q}aqR_44yHl!{A}ax+Vmbd>ax^K(JMx@q}Exk@@| zrFqFEnLrgKI;oQ<6o|B6{?54l@^>b?&pZX06{$ICsVTPAwL0xwubF|E1&CRJm<@>8 zftUk`If0l9h`E872Z(urm~T7RYkreY(_QWg^q9lU(aWezDM~C!^~uamEw+VQtXW-_ zSfo&5n^UZpo?4=zlmn7h(zKrb=&pb|SDvj#vaO0nvZm&A;d=rFcC|WKjnmN7QPIHV bV~~ju?@mAO%OpSD_X{K6_T%>iZnFRYEHZQ% delta 163 zcmeA?;k@X$bHf(K+21*p^pf*)b5rw5rYn45lx#o!opJl=?@S?|+l^i`12GE_vjQ<2 z5VHd@2M}`tF&7YX12GQ}^8zv7cB9w)x}Vs}5{nc{tf$A{73dKvvCS#gOHVD)P|C^7 xPAyi_)S0eyPe7eD*;Yj(dHTEWj8fAx?g>P5>ZoWa>4B7hoM63O@4moo764z_LBs$6 diff --git a/public/js/timeline.js b/public/js/timeline.js index fde930740d02785c60b37cea4fbee031d1bb0b07..548ff63d5fe390367b675cb6a4c24cd9efb28fc8 100644 GIT binary patch delta 68 zcmX@g`kQsbekL2e{5%b%#Daprfl1!jTs!pCxiDq>{W<_dFT55`3MrBG- UVo9n`W_D_^hGs1Y)@oV<0BJ!O#{d8T delta 14 Vcmey(dX#m;ekQhB&DvT`YXB_(1x5e> diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 9ec6355273bd68d4733621d438a98427a91289d2..c58ecdb81f8f82bfc42e8fe83215e03e22fd37d8 100644 GIT binary patch delta 54 zcmdnNxPx(mvWQW#S+a$JWum!Znu&3;v2jX@Nzz2~EOEoclvE3&#FUieWJ6QqRFkwc JGczTwS^&6R57qzx delta 54 zcmdnNxPx(mvWSVfMQUPlvY~mRL29B|T2i91q2)yLEb+ADWDB!IOA|xOBxB=53nRm1 JBV#45S^&Tg4|D(k diff --git a/resources/assets/js/bootstrap.js b/resources/assets/js/bootstrap.js index 6db7d4c98..e7da88eff 100644 --- a/resources/assets/js/bootstrap.js +++ b/resources/assets/js/bootstrap.js @@ -9,6 +9,7 @@ window.Popper = require('popper.js').default; */ try { + window.pixelfed = {}; window.$ = window.jQuery = require('jquery'); require('bootstrap'); window.InfiniteScroll = require('infinite-scroll'); diff --git a/resources/assets/js/components/commentform.js b/resources/assets/js/components/commentform.js index c7de6b42e..159a91531 100644 --- a/resources/assets/js/components/commentform.js +++ b/resources/assets/js/components/commentform.js @@ -5,7 +5,7 @@ $(document).ready(function() { el.focus(); }); - $('.comment-form').submit(function(e, data) { + $(document).on('submit', '.comment-form', function(e, data) { e.preventDefault(); let el = $(this); diff --git a/resources/assets/js/components/likebutton.js b/resources/assets/js/components/likebutton.js index 9ea111ac8..4283fcf1d 100644 --- a/resources/assets/js/components/likebutton.js +++ b/resources/assets/js/components/likebutton.js @@ -11,9 +11,8 @@ $(document).ready(function() { }) } - hydrateLikes(); - function hydrateLikes() { + pixelfed.hydrateLikes = function() { var likes = ls.get('likes'); $('.like-form').each(function(i, el) { var el = $(el); @@ -24,9 +23,11 @@ $(document).ready(function() { 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(); var el = $(this); var id = el.data('id'); diff --git a/resources/assets/js/timeline.js b/resources/assets/js/timeline.js index 02ffbb239..576b3e71e 100644 --- a/resources/assets/js/timeline.js +++ b/resources/assets/js/timeline.js @@ -6,4 +6,7 @@ $(document).ready(function() { append: '.timeline-feed', history: false, }); + infScroll.on( 'append', function( response, path, items ) { + pixelfed.hydrateLikes(); + }); }); \ No newline at end of file