Merge pull request #1736 from pixelfed/staging

Staging
This commit is contained in:
daniel 2019-09-30 22:39:49 -06:00 committed by GitHub
commit a2f4682743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 28 deletions

View File

@ -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;
});

View File

@ -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,

View File

@ -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,

View File

@ -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 => {

View File

@ -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();
}