File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -377,7 +377,7 @@ const ChannelInner = <
377377
378378 const markReadThrottled = throttle ( markRead , 500 , { leading : true , trailing : true } ) ;
379379
380- const handleEvent = ( event : Event < StreamChatGenerics > ) => {
380+ const handleEvent = async ( event : Event < StreamChatGenerics > ) => {
381381 if ( event . message ) {
382382 dispatch ( {
383383 channel,
@@ -434,6 +434,18 @@ const ChannelInner = <
434434 }
435435 }
436436
437+ if ( event . type === 'user.deleted' ) {
438+ const oldestID = channel . state ?. messages ?. [ 0 ] ?. id ;
439+
440+ /**
441+ * As the channel state is not normalized we re-fetch the channel data. Thus we avoid having to search for user references in the channel state.
442+ */
443+ await channel . query ( {
444+ messages : { id_lt : oldestID , limit : DEFAULT_NEXT_CHANNEL_PAGE_SIZE } ,
445+ watchers : { limit : DEFAULT_NEXT_CHANNEL_PAGE_SIZE } ,
446+ } ) ;
447+ }
448+
437449 throttledCopyStateFromChannel ( ) ;
438450 } ;
439451
You can’t perform that action at this time.
0 commit comments