File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -214,9 +214,11 @@ export default function MessageArea({
214214 useEffect ( ( ) => {
215215 if ( ! channelId ) return ;
216216
217- setIsLoading ( true ) ;
218217 setReplyTo ( null ) ; // Clear reply when switching channels
219218
219+ // Only show loading spinner if fetch takes longer than 300ms to avoid flash
220+ const loadingTimer = setTimeout ( ( ) => setIsLoading ( true ) , 300 ) ;
221+
220222 const fetchMessages = async ( ) => {
221223 try {
222224 const res = await fetch ( `/api/messages?channelId=${ channelId } ` ) ;
@@ -234,6 +236,7 @@ export default function MessageArea({
234236 console . error ( "Failed to fetch messages:" , error ) ;
235237 setMessages ( [ ] ) ;
236238 } finally {
239+ clearTimeout ( loadingTimer ) ;
237240 setIsLoading ( false ) ;
238241 }
239242 } ;
@@ -284,6 +287,7 @@ export default function MessageArea({
284287 } ;
285288
286289 return ( ) => {
290+ clearTimeout ( loadingTimer ) ;
287291 eventSource . close ( ) ;
288292 setTypingUsers ( new Map ( ) ) ;
289293 } ;
You can’t perform that action at this time.
0 commit comments