]> Untitled Git - lemmy-ui.git/commitdiff
Rejoin websocket rooms on reconnect. Fixes #41
authorDessalines <tyhou13@gmx.com>
Fri, 25 Sep 2020 16:47:29 +0000 (11:47 -0500)
committerDessalines <tyhou13@gmx.com>
Fri, 25 Sep 2020 16:47:29 +0000 (11:47 -0500)
src/shared/components/community.tsx
src/shared/components/main.tsx
src/shared/components/navbar.tsx
src/shared/components/post.tsx

index e994d0bb1ae9c21172491d55e047c6a6910b02ce..2fae8304cd094e4179bf1b622ee2bf13b42ef92e 100644 (file)
@@ -417,6 +417,9 @@ export class Community extends Component<any, State> {
       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;
index 7a5f8144c44b0269681d655299fb0068886993bb..3489761c8ea6ff145b84179e0d8ac24227c0c813 100644 (file)
@@ -720,6 +720,7 @@ export class Main extends Component<any, MainState> {
       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;
index 5a10b6ab8910fa0cd8b28be84bdf9585d8aa48f2..877cdd8e58d2dfa4df3d2abab8b4a461b81d50e7 100644 (file)
@@ -392,6 +392,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
       }
       return;
     } else if (msg.reconnect) {
+      WebSocketService.Instance.userJoin();
       this.fetchUnreads();
     } else if (res.op == UserOperation.GetReplies) {
       let data = res.data as GetRepliesResponse;
index a7c9f79494f8205fb2e938df38baf167901126ec..201085843be899b69b7aad71896fcb5ae9266df3 100644 (file)
@@ -436,8 +436,10 @@ export class Post extends Component<any, PostState> {
       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;