File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -393,6 +393,11 @@ export const Channel = <
393393 // The more complex sync logic is done in Chat.js
394394 // listen to client.connection.recovered and all channel events
395395 client . on ( 'connection.recovered' , handleEvent ) ;
396+ client . on ( 'connection.changed' , ( e ) => {
397+ if ( e . online ) {
398+ reloadChannel ( ) ;
399+ }
400+ } ) ;
396401 channel ?. on ( handleEvent ) ;
397402 } ;
398403
@@ -418,6 +423,21 @@ export const Channel = <
418423 }
419424 } ;
420425
426+ const reloadChannel = async ( ) => {
427+ setError ( false ) ;
428+ if ( channel && channel . cid ) {
429+ try {
430+ await channel . watch ( ) ;
431+ } catch ( err ) {
432+ setError ( err ) ;
433+ return ;
434+ }
435+
436+ setLastRead ( new Date ( ) ) ;
437+ copyChannelState ( ) ;
438+ }
439+ } ;
440+
421441 /**
422442 * MESSAGE METHODS
423443 */
You can’t perform that action at this time.
0 commit comments