mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-12-22 19:01:26 +00:00
Adding support for join messages. Fixes #8
This commit is contained in:
parent
2295bd4d88
commit
fd43a890a7
6 changed files with 24 additions and 6 deletions
|
@ -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",
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -134,6 +134,7 @@ export class Post extends Component<any, PostState> {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
WebSocketService.Instance.postJoin({ post_id: this.state.postId });
|
||||
autosize(document.querySelectorAll('textarea'));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue