Update StatusController

This commit is contained in:
Daniel Supernault 2018-11-08 22:29:57 -07:00
parent 454ae2166c
commit bbc56b74da
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 1 additions and 29 deletions

View File

@ -23,7 +23,6 @@ class StatusController extends Controller
$status = Status::whereProfileId($user->id) $status = Status::whereProfileId($user->id)
->where('visibility', '!=', 'draft') ->where('visibility', '!=', 'draft')
->withCount(['likes', 'comments', 'media'])
->findOrFail($id); ->findOrFail($id);
if($status->visibility == 'private' || $user->is_private) { if($status->visibility == 'private' || $user->is_private) {
@ -40,34 +39,7 @@ class StatusController extends Controller
return $this->showActivityPub($request, $status); return $this->showActivityPub($request, $status);
} }
$template = $this->detectTemplate($status); return view('status.show', compact('user', 'status'));
$replies = Status::whereInReplyToId($status->id)->orderBy('created_at', 'desc')->simplePaginate(30);
return view($template, compact('user', 'status', 'replies'));
}
protected function detectTemplate($status)
{
$template = Cache::rememberForever('template:status:type:'.$status->id, function () use ($status) {
$template = 'status.show.photo';
if (!$status->media_path && $status->in_reply_to_id) {
$template = 'status.reply';
}
if ($status->media->count() > 1) {
$template = 'status.show.album';
}
if ($status->viewType() == 'video') {
$template = 'status.show.video';
}
if ($status->viewType() == 'video-album') {
$template = 'status.show.video-album';
}
return $template;
});
return $template;
} }
public function compose() public function compose()