restore topic subscription after a reconnect
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user