diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 7874ed2db..3d70d4b7f 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -49,18 +49,26 @@ class BaseApiController extends Controller { abort_if(!$request->user(), 403); $pid = $request->user()->profile_id; - $this->validate($request, [ - 'page' => 'nullable|integer|min:1|max:10', - 'limit' => 'nullable|integer|min:1|max:40' - ]); - $limit = $request->input('limit') ?? 10; - $timeago = Carbon::now()->subMonths(6); - $notifications = Notification::whereProfileId($pid) - ->whereDate('created_at', '>', $timeago) - ->latest() - ->simplePaginate($limit); - $resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer()); - $res = $this->fractal->createData($resource)->toArray(); + $pg = $request->input('pg'); + if($pg == true) { + $timeago = Carbon::now()->subMonths(6); + $notifications = Notification::whereProfileId($pid) + ->whereDate('created_at', '>', $timeago) + ->latest() + ->simplePaginate(10); + $resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer()); + $res = $this->fractal->createData($resource)->toArray(); + } else { + $this->validate($request, [ + 'page' => 'nullable|integer|min:1|max:10', + 'limit' => 'nullable|integer|min:1|max:40' + ]); + $limit = $request->input('limit') ?? 10; + $page = $request->input('page') ?? 1; + $end = (int) $page * $limit; + $start = (int) $end - $limit; + $res = NotificationService::get($pid, $start, $end); + } return response()->json($res); } @@ -307,13 +315,6 @@ class BaseApiController extends Controller $profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail(); $resource = new Fractal\Resource\Item($profile, new AccountTransformer()); $res = $this->fractal->createData($resource)->toArray(); - $res['source'] = [ - 'privacy' => $profile->is_private ? 'private' : 'public', - 'sensitive' => $profile->cw ? true : false, - 'language' => 'en', - 'note' => '', - 'fields' => [] - ]; return $res; }); diff --git a/app/Transformer/Api/Mastodon/v1/StatusTransformer.php b/app/Transformer/Api/Mastodon/v1/StatusTransformer.php index 2cd6f123f..97f0cb4b8 100644 --- a/app/Transformer/Api/Mastodon/v1/StatusTransformer.php +++ b/app/Transformer/Api/Mastodon/v1/StatusTransformer.php @@ -28,8 +28,8 @@ class StatusTransformer extends Fractal\TransformerAbstract 'created_at' => $status->created_at->toJSON(), 'emojis' => [], 'replies_count' => 0, - 'reblogs_count' => $status->reblogs_count != 0 ? $status->reblogs_count: $status->shares()->count(), - 'favourites_count' => $status->likes_count != 0 ? $status->likes_count: $status->likes()->count(), + 'reblogs_count' => $status->reblogs_count, + 'favourites_count' => $status->likes_count, 'reblogged' => null, 'favourited' => null, 'muted' => null, diff --git a/app/Transformer/Api/StatusTransformer.php b/app/Transformer/Api/StatusTransformer.php index 5b251501e..c03a501f6 100644 --- a/app/Transformer/Api/StatusTransformer.php +++ b/app/Transformer/Api/StatusTransformer.php @@ -25,8 +25,8 @@ class StatusTransformer extends Fractal\TransformerAbstract 'content' => $status->rendered ?? $status->caption, 'created_at' => $status->created_at->format('c'), 'emojis' => [], - 'reblogs_count' => $status->reblogs_count != 0 ? $status->reblogs_count: $status->shares()->count(), - 'favourites_count' => $status->likes_count != 0 ? $status->likes_count: $status->likes()->count(), + 'reblogs_count' => $status->reblogs_count, + 'favourites_count' => $status->likes_count, 'reblogged' => $status->shared(), 'favourited' => $status->liked(), 'muted' => null, diff --git a/resources/assets/js/components/Activity.vue b/resources/assets/js/components/Activity.vue index 654e67ebf..f0e217e24 100644 --- a/resources/assets/js/components/Activity.vue +++ b/resources/assets/js/components/Activity.vue @@ -115,7 +115,11 @@ export default { methods: { fetchNotifications() { - axios.get('/api/pixelfed/v1/notifications') + axios.get('/api/pixelfed/v1/notifications', { + params: { + pg: true + } + }) .then(res => { let data = res.data.filter(n => { if(n.type == 'share' && !status) { @@ -138,6 +142,7 @@ export default { } axios.get('/api/pixelfed/v1/notifications', { params: { + pg: true, page: this.notificationCursor } }).then(res => { diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index a6904c652..fdf8c1233 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -304,7 +304,7 @@ -