mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 02:24:31 +00:00
Update Timeline.vue, batch api views
This commit is contained in:
parent
444c6d5163
commit
3de44f3392
2 changed files with 25 additions and 13 deletions
|
@ -403,20 +403,28 @@ class StatusController extends Controller
|
||||||
public function storeView(Request $request)
|
public function storeView(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 403);
|
abort_if(!$request->user(), 403);
|
||||||
|
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'status_id' => 'required|integer|exists:statuses,id',
|
'_v' => 'required|array'
|
||||||
'profile_id' => 'required|integer|exists:profiles,id'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sid = (int) $request->input('status_id');
|
$views = $request->input('_v');
|
||||||
$pid = (int) $request->input('profile_id');
|
$uid = $request->user()->profile_id;
|
||||||
|
|
||||||
StatusView::firstOrCreate([
|
if(empty($views)) {
|
||||||
'status_id' => $sid,
|
return;
|
||||||
'status_profile_id' => $pid,
|
}
|
||||||
'profile_id' => $request->user()->profile_id
|
|
||||||
]);
|
foreach($views as $view) {
|
||||||
|
if(!isset($view['sid']) || !isset($view['pid'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusView::firstOrCreate([
|
||||||
|
'status_id' => $view['sid'],
|
||||||
|
'status_profile_id' => $view['pid'],
|
||||||
|
'profile_id' => $uid
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return response()->json(1);
|
return response()->json(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1076,13 +1076,14 @@
|
||||||
if (res.data.length && this.loading == false) {
|
if (res.data.length && this.loading == false) {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
let self = this;
|
let self = this;
|
||||||
|
let vids = [];
|
||||||
data.forEach((d, index) => {
|
data.forEach((d, index) => {
|
||||||
if(self.ids.indexOf(d.id) == -1) {
|
if(self.ids.indexOf(d.id) == -1) {
|
||||||
self.feed.push(d);
|
self.feed.push(d);
|
||||||
self.ids.push(d.id);
|
self.ids.push(d.id);
|
||||||
axios.post('/api/status/view', {
|
vids.push({
|
||||||
'status_id': d.id,
|
sid: d.id,
|
||||||
'profile_id': d.account.id
|
pid: d.account.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1091,6 +1092,9 @@
|
||||||
this.page += 1;
|
this.page += 1;
|
||||||
$state.loaded();
|
$state.loaded();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
axios.post('/api/status/view', {
|
||||||
|
'_v': vids,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$state.complete();
|
$state.complete();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue