From: Dessalines Date: Fri, 25 Sep 2020 16:47:29 +0000 (-0500) Subject: Rejoin websocket rooms on reconnect. Fixes #41 X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%7B?a=commitdiff_plain;h=4f5d70d5b5e136a5c2f19dc7718eeef432319b70;p=lemmy-ui.git Rejoin websocket rooms on reconnect. Fixes #41 --- diff --git a/src/shared/components/community.tsx b/src/shared/components/community.tsx index e994d0b..2fae830 100644 --- a/src/shared/components/community.tsx +++ b/src/shared/components/community.tsx @@ -417,6 +417,9 @@ export class Community extends Component { this.context.router.history.push('/'); return; } else if (msg.reconnect) { + WebSocketService.Instance.communityJoin({ + community_id: this.state.communityRes.community.id, + }); this.fetchData(); } else if (res.op == UserOperation.GetCommunity) { let data = res.data as GetCommunityResponse; diff --git a/src/shared/components/main.tsx b/src/shared/components/main.tsx index 7a5f814..3489761 100644 --- a/src/shared/components/main.tsx +++ b/src/shared/components/main.tsx @@ -720,6 +720,7 @@ export class Main extends Component { toast(i18n.t(msg.error), 'danger'); return; } else if (msg.reconnect) { + WebSocketService.Instance.communityJoin({ community_id: 0 }); this.fetchData(); } else if (res.op == UserOperation.GetFollowedCommunities) { let data = res.data as GetFollowedCommunitiesResponse; diff --git a/src/shared/components/navbar.tsx b/src/shared/components/navbar.tsx index 5a10b6a..877cdd8 100644 --- a/src/shared/components/navbar.tsx +++ b/src/shared/components/navbar.tsx @@ -392,6 +392,7 @@ export class Navbar extends Component { } return; } else if (msg.reconnect) { + WebSocketService.Instance.userJoin(); this.fetchUnreads(); } else if (res.op == UserOperation.GetReplies) { let data = res.data as GetRepliesResponse; diff --git a/src/shared/components/post.tsx b/src/shared/components/post.tsx index a7c9f79..2010858 100644 --- a/src/shared/components/post.tsx +++ b/src/shared/components/post.tsx @@ -436,8 +436,10 @@ export class Post extends Component { toast(i18n.t(msg.error), 'danger'); return; } else if (msg.reconnect) { + let postId = Number(this.props.match.params.id); + WebSocketService.Instance.postJoin({ post_id: postId }); WebSocketService.Instance.getPost({ - id: Number(this.props.match.params.id), + id: postId, }); } else if (res.op == UserOperation.GetPost) { let data = res.data as GetPostResponse;