Defer profile favourites until needed

This commit is contained in:
2026-08-30 07:30:15 +02:00
parent 187292a374
commit dba1f73e01
7 changed files with 276 additions and 15 deletions
@@ -1011,14 +1011,17 @@ class ProfileController extends Controller
? $this->loadFeaturedArtworks($user, $viewer)
: null;
// ── Favourites ───────────────────────────────────────────────────────
$favouriteLimit = 12;
$favouriteTable = $this->resolveFavouriteTable();
$favourites = [
'data' => [],
'next_cursor' => null,
];
if ($favouriteTable !== null) {
// ── Favourites (only needed for the direct Favourites tab) ───────────
$favourites = null;
if ($initialTab === 'favourites') {
$favouriteLimit = 12;
$favouriteTable = $this->resolveFavouriteTable();
$favourites = [
'data' => [],
'next_cursor' => null,
];
}
if ($favourites !== null && $favouriteTable !== null) {
$favIds = DB::table($favouriteTable . ' as af')
->join('artworks as a', 'a.id', '=', 'af.artwork_id')
->where('af.user_id', $user->id)