@@ -29,14 +29,17 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
29
29
30
30
const [ id ] = useChatStore ( ( s ) => [ chatSelectors . currentChatKey ( s ) ] ) ;
31
31
32
- const [ activeTopicId , useFetchMessages , isFirstLoading ] = useChatStore ( ( s ) => [
33
- s . activeTopicId ,
34
- s . useFetchMessages ,
35
- chatSelectors . currentChatLoadingState ( s ) ,
36
- ] ) ;
32
+ const [ activeTopicId , useFetchMessages , isFirstLoading , isCurrentChatLoaded ] = useChatStore (
33
+ ( s ) => [
34
+ s . activeTopicId ,
35
+ s . useFetchMessages ,
36
+ chatSelectors . currentChatLoadingState ( s ) ,
37
+ chatSelectors . isCurrentChatLoaded ( s ) ,
38
+ ] ,
39
+ ) ;
37
40
38
41
const [ sessionId ] = useSessionStore ( ( s ) => [ s . activeId ] ) ;
39
- const { isLoading } = useFetchMessages ( sessionId , activeTopicId ) ;
42
+ useFetchMessages ( sessionId , activeTopicId ) ;
40
43
41
44
const data = useChatStore ( ( s ) => {
42
45
const showInboxWelcome = chatSelectors . showInboxWelcome ( s ) ;
@@ -77,23 +80,26 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
77
80
[ mobile ] ,
78
81
) ;
79
82
80
- // first time loading
83
+ // first time loading or not loaded
81
84
if ( isFirstLoading ) return < SkeletonList mobile = { mobile } /> ;
82
85
83
- // in server mode and switch page
84
- if ( isServerMode && isLoading ) return < SkeletonList mobile = { mobile } /> ;
85
-
86
- // in client mode using the center loading for more
87
- return isLoading ? (
88
- < Center height = { '100%' } width = { '100%' } >
89
- < Icon
90
- icon = { Loader2Icon }
91
- size = { { fontSize : 32 } }
92
- spin
93
- style = { { color : theme . colorTextTertiary } }
94
- />
95
- </ Center >
96
- ) : (
86
+ if ( ! isCurrentChatLoaded )
87
+ // use skeleton list when not loaded in server mode due to the loading duration is much longer than client mode
88
+ return isServerMode ? (
89
+ < SkeletonList mobile = { mobile } />
90
+ ) : (
91
+ // in client mode and switch page, using the center loading for smooth transition
92
+ < Center height = { '100%' } width = { '100%' } >
93
+ < Icon
94
+ icon = { Loader2Icon }
95
+ size = { { fontSize : 32 } }
96
+ spin
97
+ style = { { color : theme . colorTextTertiary } }
98
+ />
99
+ </ Center >
100
+ ) ;
101
+
102
+ return (
97
103
< Flexbox height = { '100%' } >
98
104
< Virtuoso
99
105
atBottomStateChange = { setAtBottom }
0 commit comments