mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
commit
a2f4682743
5 changed files with 34 additions and 28 deletions
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -304,7 +304,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="modes.notify == true" class="mb-4">
|
||||
<div v-show="modes.notify == true && !loading" class="mb-4">
|
||||
<notification-card></notification-card>
|
||||
</div>
|
||||
|
||||
|
@ -606,9 +606,9 @@
|
|||
this.max_id = Math.min(...ids);
|
||||
this.loading = false;
|
||||
$('.timeline .pagination').removeClass('d-none');
|
||||
if(this.feed.length == 4) {
|
||||
this.fetchTimelineApi();
|
||||
}
|
||||
// if(this.feed.length == 4) {
|
||||
// this.fetchTimelineApi();
|
||||
// }
|
||||
if(this.hashtagPosts.length == 0) {
|
||||
this.fetchHashtagPosts();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue