restore topic subscription after a reconnect

This commit is contained in:
or-else
2026-03-01 18:31:24 +03:00
parent 389ef305ab
commit e6dfde28f6
14 changed files with 306 additions and 37 deletions
+3
View File
@@ -326,6 +326,9 @@ class MessagesView extends React.Component {
} else if (topic.isSubscribed() && this.state.isReader && !prevState.isReader) {
// If reader status has changed and data became available.
topic.getMeta(topic.startMetaQuery().withLaterData().build());
} else if (!topic.isSubscribed() && this.props.ready && !prevProps.ready) {
// Connection restored (e.g. wake from sleep): resubscribe to the currently open topic.
this.subscribe(topic);
}
}
}
+3 -1
View File
@@ -853,7 +853,9 @@ class TinodeWeb extends React.Component {
LocalStorageUtil.setObject('auth-token', this.tinode.getAuthToken());
}
const goToTopic = this.state.requestedTopic;
// On reconnect, requestedTopic is undefined but topicSelected may still be set.
// Preserve the open topic so it gets restored after re-login.
const goToTopic = this.state.requestedTopic || this.state.topicSelected;
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
const me = this.tinode.getMeTopic();
me.onMetaDesc = this.tnMeMetaDesc;