Defer profile world history until needed

This commit is contained in:
test
2026-08-30 12:02:07 +02:00
parent 5c80402aed
commit 937f484cc9
8 changed files with 282 additions and 11 deletions
+8 -2
View File
@@ -17,6 +17,7 @@ import TabFollowers from '../../components/profile/tabs/TabFollowers'
import GroupProfileSummary from '../../components/groups/GroupProfileSummary'
import useLazyProfileFeaturedArtworks from '../../lib/useLazyProfileFeaturedArtworks'
import useLazyProfileFavourites from '../../lib/useLazyProfileFavourites'
import useLazyProfileWorldHistory from '../../lib/useLazyProfileWorldHistory'
const VALID_TABS = ['posts', 'artworks', 'stories', 'achievements', 'worlds', 'collections', 'about', 'stats', 'favourites', 'activity', 'followers']
@@ -98,6 +99,11 @@ export default function ProfileShow() {
initialFavourites: favourites,
enabled: activeTab === 'favourites',
})
const worldHistoryState = useLazyProfileWorldHistory({
username: user?.username || user?.name || '',
initialWorldHistory: worldHistory,
enabled: activeTab === 'worlds' || activeTab === 'achievements',
})
const handleTabChange = useCallback((tab) => {
if (!VALID_TABS.includes(tab)) return
@@ -239,10 +245,10 @@ export default function ProfileShow() {
/>
)}
{activeTab === 'achievements' && (
<TabAchievements achievements={achievements} worldRewards={worldRewards} worldHistory={worldHistory} onTabChange={handleTabChange} />
<TabAchievements achievements={achievements} worldRewards={worldRewards} worldHistory={worldHistoryState.data} onTabChange={handleTabChange} />
)}
{activeTab === 'worlds' && (
<TabWorlds worldHistory={worldHistory} isOwner={isOwner} />
<TabWorlds worldHistory={worldHistoryState.data} isOwner={isOwner} loading={worldHistoryState.loading} error={worldHistoryState.error} onRetry={worldHistoryState.retry} />
)}
{activeTab === 'collections' && (
<TabCollections