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;
$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, [ $this->validate($request, [
'page' => 'nullable|integer|min:1|max:10', 'page' => 'nullable|integer|min:1|max:10',
'limit' => 'nullable|integer|min:1|max:40' 'limit' => 'nullable|integer|min:1|max:40'
]); ]);
$limit = $request->input('limit') ?? 10; $limit = $request->input('limit') ?? 10;
$timeago = Carbon::now()->subMonths(6); $page = $request->input('page') ?? 1;
$notifications = Notification::whereProfileId($pid) $end = (int) $page * $limit;
->whereDate('created_at', '>', $timeago) $start = (int) $end - $limit;
->latest() $res = NotificationService::get($pid, $start, $end);
->simplePaginate($limit); }
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
$res = $this->fractal->createData($resource)->toArray();
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();
} }