]> Untitled Git - lemmy-ui.git/commitdiff
Adding support for join messages. Fixes #8
authorDessalines <tyhou13@gmx.com>
Sun, 13 Sep 2020 15:37:23 +0000 (10:37 -0500)
committerDessalines <tyhou13@gmx.com>
Sun, 13 Sep 2020 15:37:23 +0000 (10:37 -0500)
package.json
src/shared/components/community.tsx
src/shared/components/main.tsx
src/shared/components/post.tsx
src/shared/services/WebSocketService.ts
yarn.lock

index a74114a84d5911a2798b0838bec6fa183f5dd16e..78f2d9cbffd0abf9573e0fa1a35520479214fb69 100644 (file)
@@ -72,7 +72,7 @@
     "eslint": "^7.8.1",
     "eslint-plugin-jane": "^9.0.0",
     "husky": "^4.3.0",
-    "lemmy-js-client": "^1.0.11",
+    "lemmy-js-client": "^1.0.13",
     "lint-staged": "^10.3.0",
     "mini-css-extract-plugin": "^0.11.1",
     "node-fetch": "^2.6.1",
index 7deb62b7332792c40c2ce2203dd1f57893c26394..b76a21655412b5f5ae300a9576acd96221883a21 100644 (file)
@@ -425,6 +425,9 @@ export class Community extends Component<any, State> {
         this.state.loading = false;
       }
       this.setState(this.state);
+      WebSocketService.Instance.communityJoin({
+        community_id: data.community.id,
+      });
     } else if (
       res.op == UserOperation.EditCommunity ||
       res.op == UserOperation.DeleteCommunity ||
index 62010f527053cf6d6518f509f4ecf8510dd76cd7..33d79ec16490987c795030639416bb3f4e14ac8e 100644 (file)
@@ -151,6 +151,10 @@ export class Main extends Component<any, MainState> {
     WebSocketService.Instance.listCommunities(listCommunitiesForm);
   }
 
+  componentDidMount() {
+    WebSocketService.Instance.communityJoin({ community_id: 0 });
+  }
+
   componentWillUnmount() {
     if (isBrowser()) {
       this.subscription.unsubscribe();
index 6f1bf6dba787df7cacc3018e36beb9d6ad36fbfb..a7c9f79494f8205fb2e938df38baf167901126ec 100644 (file)
@@ -134,6 +134,7 @@ export class Post extends Component<any, PostState> {
   }
 
   componentDidMount() {
+    WebSocketService.Instance.postJoin({ post_id: this.state.postId });
     autosize(document.querySelectorAll('textarea'));
   }
 
index 646f9de90f125ded6d2855510191ab46549a1ff6..634a9b7ca0d96069919fbdd64a6c8250704778b9 100644 (file)
@@ -55,6 +55,8 @@ import {
   SiteConfigForm,
   MarkAllAsReadForm,
   WebSocketJsonResponse,
+  CommunityJoinForm,
+  PostJoinForm,
 } from 'lemmy-js-client';
 import { UserService } from './';
 import { i18n } from '../i18next';
@@ -85,7 +87,7 @@ export class WebSocketService {
     this.ws = new ReconnectingWebSocket(wsUri, [], this.wsOptions);
     let firstConnect = true;
 
-    this.subject = Observable.create((obs: any) => {
+    this.subject = new Observable((obs: any) => {
       this.ws.onmessage = e => {
         obs.next(JSON.parse(e.data));
       };
@@ -113,6 +115,14 @@ export class WebSocketService {
     this.ws.send(this.client.userJoin(form));
   }
 
+  public postJoin(form: PostJoinForm) {
+    this.ws.send(this.client.postJoin(form));
+  }
+
+  public communityJoin(form: CommunityJoinForm) {
+    this.ws.send(this.client.communityJoin(form));
+  }
+
   public login(form: LoginForm) {
     this.ws.send(this.client.login(form));
   }
index 659250a1d0d507292dab911314b957a80863094b..ddef340654f131634d5c88bde1d9e69a6f81cac4 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -5827,10 +5827,10 @@ lcid@^1.0.0:
   dependencies:
     invert-kv "^1.0.0"
 
-lemmy-js-client@^1.0.11:
-  version "1.0.11"
-  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.11.tgz#f6ccdd5f4bf60c9ec49a4337c92d91933c0d00c2"
-  integrity sha512-bMvCKcP76YpSYhVSX0hGnhf9DQWpu7j4UQG2ektbpsmTi+yA4JiZKsLQXwgQH7hty42EHV0ZJVBNUpqlKnGFrA==
+lemmy-js-client@^1.0.13:
+  version "1.0.13"
+  resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-1.0.13.tgz#d0e1246129ade295faeec1fb4b2c7397d6947a19"
+  integrity sha512-Xz87cCswi/2pbDdApw9JIy8bDWRFGiGWO6IhehTytOAzf36dr4GYgsjTQTLjBX+s+BNYr8hE0+Sz4g9c+ynoJg==
 
 leven@^3.1.0:
   version "3.1.0"