From 9f8957b939c1c71a59ebf91571a507b4fa277873 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 16 Feb 2023 23:03:15 -0700 Subject: [PATCH] Update ComposeController, fix add to collection logic --- app/Http/Controllers/ComposeController.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ComposeController.php b/app/Http/Controllers/ComposeController.php index 848e0c45..ad52807c 100644 --- a/app/Http/Controllers/ComposeController.php +++ b/app/Http/Controllers/ComposeController.php @@ -41,6 +41,7 @@ use App\Jobs\VideoPipeline\{ VideoThumbnail }; use App\Services\AccountService; +use App\Services\CollectionService; use App\Services\NotificationService; use App\Services\MediaPathService; use App\Services\MediaBlocklistService; @@ -585,13 +586,24 @@ class ComposeController extends Controller $collections = Collection::whereProfileId($profile->id) ->find($request->input('collections')) ->each(function($collection) use($status) { + $count = $collection->items()->count(); CollectionItem::firstOrCreate([ 'collection_id' => $collection->id, 'object_type' => 'App\Status', 'object_id' => $status->id ], [ - 'order' => $collection->items()->count() + 'order' => $count ]); + + CollectionService::addItem( + $collection->id, + $status->id, + $count + ); + + $collection->updated_at = now(); + $collection->save(); + CollectionService::setCollection($collection->id, $collection); }); }