Defer profile world history until needed
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user