Defer profile world history until needed
This commit is contained in:
@@ -63,6 +63,8 @@ use Inertia\Inertia;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
private const SSR_WORLD_HISTORY_TABS = ['achievements', 'worlds'];
|
||||
|
||||
private const PROFILE_TABS = [
|
||||
'posts',
|
||||
'artworks',
|
||||
@@ -207,6 +209,26 @@ class ProfileController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read-only world history payload for profile tabs that are loaded client-side.
|
||||
* This deliberately does not render the profile document or track a view.
|
||||
*/
|
||||
public function worldHistory(Request $request, string $username): JsonResponse
|
||||
{
|
||||
$normalized = UsernamePolicy::normalize($username);
|
||||
$user = User::query()->whereRaw('LOWER(username) = ?', [$normalized])->first();
|
||||
|
||||
if (! $user) {
|
||||
return response()->json(['error' => 'User not found'], 404);
|
||||
}
|
||||
|
||||
$isOwner = Auth::check() && Auth::id() === $user->id;
|
||||
|
||||
return response()->json($isOwner
|
||||
? $this->worldProfileHistory->ownerPayloadForUser($user)
|
||||
: $this->worldProfileHistory->publicPayloadForUser($user));
|
||||
}
|
||||
|
||||
public function legacyById(Request $request, int $id, ?string $username = null)
|
||||
{
|
||||
$user = User::query()->findOrFail($id);
|
||||
@@ -1292,9 +1314,11 @@ class ProfileController extends Controller
|
||||
->all();
|
||||
$achievementSummary = $this->achievements->summary((int) $user->id);
|
||||
$worldRewardSummary = $this->worldRewards->summaryForUser($user);
|
||||
$worldHistory = $isOwner
|
||||
? $this->worldProfileHistory->ownerPayloadForUser($user)
|
||||
: $this->worldProfileHistory->publicPayloadForUser($user);
|
||||
$worldHistory = in_array($initialTab, self::SSR_WORLD_HISTORY_TABS, true)
|
||||
? ($isOwner
|
||||
? $this->worldProfileHistory->ownerPayloadForUser($user)
|
||||
: $this->worldProfileHistory->publicPayloadForUser($user))
|
||||
: null;
|
||||
$leaderboardRank = $this->leaderboards->creatorRankSummary((int) $user->id);
|
||||
$groupContributionHistory = $this->buildGroupContributionHistory($user);
|
||||
$journey = $this->creatorJourney->publicPayloadForUser($user);
|
||||
|
||||
Reference in New Issue
Block a user