Rejoin websocket rooms on reconnect. Fixes #41

This commit is contained in:
Dessalines 2020-09-25 11:47:29 -05:00
parent 3ff9b46981
commit 4f5d70d5b5
4 changed files with 8 additions and 1 deletions

View file

@ -417,6 +417,9 @@ export class Community extends Component<any, State> {
this.context.router.history.push('/'); this.context.router.history.push('/');
return; return;
} else if (msg.reconnect) { } else if (msg.reconnect) {
WebSocketService.Instance.communityJoin({
community_id: this.state.communityRes.community.id,
});
this.fetchData(); this.fetchData();
} else if (res.op == UserOperation.GetCommunity) { } else if (res.op == UserOperation.GetCommunity) {
let data = res.data as GetCommunityResponse; let data = res.data as GetCommunityResponse;

View file

@ -720,6 +720,7 @@ export class Main extends Component<any, MainState> {
toast(i18n.t(msg.error), 'danger'); toast(i18n.t(msg.error), 'danger');
return; return;
} else if (msg.reconnect) { } else if (msg.reconnect) {
WebSocketService.Instance.communityJoin({ community_id: 0 });
this.fetchData(); this.fetchData();
} else if (res.op == UserOperation.GetFollowedCommunities) { } else if (res.op == UserOperation.GetFollowedCommunities) {
let data = res.data as GetFollowedCommunitiesResponse; let data = res.data as GetFollowedCommunitiesResponse;

View file

@ -392,6 +392,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
} }
return; return;
} else if (msg.reconnect) { } else if (msg.reconnect) {
WebSocketService.Instance.userJoin();
this.fetchUnreads(); this.fetchUnreads();
} else if (res.op == UserOperation.GetReplies) { } else if (res.op == UserOperation.GetReplies) {
let data = res.data as GetRepliesResponse; let data = res.data as GetRepliesResponse;

View file

@ -436,8 +436,10 @@ export class Post extends Component<any, PostState> {
toast(i18n.t(msg.error), 'danger'); toast(i18n.t(msg.error), 'danger');
return; return;
} else if (msg.reconnect) { } else if (msg.reconnect) {
let postId = Number(this.props.match.params.id);
WebSocketService.Instance.postJoin({ post_id: postId });
WebSocketService.Instance.getPost({ WebSocketService.Instance.getPost({
id: Number(this.props.match.params.id), id: postId,
}); });
} else if (res.op == UserOperation.GetPost) { } else if (res.op == UserOperation.GetPost) {
let data = res.data as GetPostResponse; let data = res.data as GetPostResponse;