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); abort_if(!$request->user(), 403);
$pid = $request->user()->profile_id; $pid = $request->user()->profile_id;
$this->validate($request, [ $pg = $request->input('pg');
'page' => 'nullable|integer|min:1|max:10', if($pg == true) {
'limit' => 'nullable|integer|min:1|max:40' $timeago = Carbon::now()->subMonths(6);
]); $notifications = Notification::whereProfileId($pid)
$limit = $request->input('limit') ?? 10; ->whereDate('created_at', '>', $timeago)
$timeago = Carbon::now()->subMonths(6); ->latest()
$notifications = Notification::whereProfileId($pid) ->simplePaginate(10);
->whereDate('created_at', '>', $timeago) $resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
->latest() $res = $this->fractal->createData($resource)->toArray();
->simplePaginate($limit); } else {
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer()); $this->validate($request, [
$res = $this->fractal->createData($resource)->toArray(); '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); return response()->json($res);
} }
@ -307,13 +315,6 @@ class BaseApiController extends Controller
$profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail(); $profile = Profile::whereNull('status')->whereUserId($id)->firstOrFail();
$resource = new Fractal\Resource\Item($profile, new AccountTransformer()); $resource = new Fractal\Resource\Item($profile, new AccountTransformer());
$res = $this->fractal->createData($resource)->toArray(); $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; return $res;
}); });

View file

@ -28,8 +28,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
'created_at' => $status->created_at->toJSON(), 'created_at' => $status->created_at->toJSON(),
'emojis' => [], 'emojis' => [],
'replies_count' => 0, 'replies_count' => 0,
'reblogs_count' => $status->reblogs_count != 0 ? $status->reblogs_count: $status->shares()->count(), 'reblogs_count' => $status->reblogs_count,
'favourites_count' => $status->likes_count != 0 ? $status->likes_count: $status->likes()->count(), 'favourites_count' => $status->likes_count,
'reblogged' => null, 'reblogged' => null,
'favourited' => null, 'favourited' => null,
'muted' => null, 'muted' => null,

View file

@ -25,8 +25,8 @@ class StatusTransformer extends Fractal\TransformerAbstract
'content' => $status->rendered ?? $status->caption, 'content' => $status->rendered ?? $status->caption,
'created_at' => $status->created_at->format('c'), 'created_at' => $status->created_at->format('c'),
'emojis' => [], 'emojis' => [],
'reblogs_count' => $status->reblogs_count != 0 ? $status->reblogs_count: $status->shares()->count(), 'reblogs_count' => $status->reblogs_count,
'favourites_count' => $status->likes_count != 0 ? $status->likes_count: $status->likes()->count(), 'favourites_count' => $status->likes_count,
'reblogged' => $status->shared(), 'reblogged' => $status->shared(),
'favourited' => $status->liked(), 'favourited' => $status->liked(),
'muted' => null, 'muted' => null,

View file

@ -115,7 +115,11 @@ export default {
methods: { methods: {
fetchNotifications() { fetchNotifications() {
axios.get('/api/pixelfed/v1/notifications') axios.get('/api/pixelfed/v1/notifications', {
params: {
pg: true
}
})
.then(res => { .then(res => {
let data = res.data.filter(n => { let data = res.data.filter(n => {
if(n.type == 'share' && !status) { if(n.type == 'share' && !status) {
@ -138,6 +142,7 @@ export default {
} }
axios.get('/api/pixelfed/v1/notifications', { axios.get('/api/pixelfed/v1/notifications', {
params: { params: {
pg: true,
page: this.notificationCursor page: this.notificationCursor
} }
}).then(res => { }).then(res => {

View file

@ -304,7 +304,7 @@
</div> </div>
</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> <notification-card></notification-card>
</div> </div>
@ -606,9 +606,9 @@
this.max_id = Math.min(...ids); this.max_id = Math.min(...ids);
this.loading = false; this.loading = false;
$('.timeline .pagination').removeClass('d-none'); $('.timeline .pagination').removeClass('d-none');
if(this.feed.length == 4) { // if(this.feed.length == 4) {
this.fetchTimelineApi(); // this.fetchTimelineApi();
} // }
if(this.hashtagPosts.length == 0) { if(this.hashtagPosts.length == 0) {
this.fetchHashtagPosts(); this.fetchHashtagPosts();
} }