diff options
author | Dessalines <tyhou13@gmx.com> | 2019-03-28 12:32:08 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-03-28 12:32:08 -0700 |
commit | 49c61fc31818e92fea00f8cd9d1c048104d8ecbf (patch) | |
tree | 3d23898c675722809f585ee81ae53ed9763fe87b /ui/src/services | |
parent | 05f0aee3ea88d3982e2efe6230f8c591540e4c92 (diff) |
Adding comment voting
- Extracting out some components.
- Fixing an issue with window refreshing websockets.
Diffstat (limited to 'ui/src/services')
-rw-r--r-- | ui/src/services/WebSocketService.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts index beefac85..ed08fa1e 100644 --- a/ui/src/services/WebSocketService.ts +++ b/ui/src/services/WebSocketService.ts @@ -1,5 +1,5 @@ import { wsUri } from '../env'; -import { LoginForm, RegisterForm, UserOperation, CommunityForm, PostForm, CommentForm } from '../interfaces'; +import { LoginForm, RegisterForm, UserOperation, CommunityForm, PostForm, CommentForm, CommentLikeForm } from '../interfaces'; import { webSocket } from 'rxjs/webSocket'; import { Subject } from 'rxjs'; import { retryWhen, delay, take } from 'rxjs/operators'; @@ -47,7 +47,8 @@ export class WebSocketService { } public getPost(postId: number) { - this.subject.next(this.wsSendWrapper(UserOperation.GetPost, {id: postId})); + let data = {id: postId, auth: UserService.Instance.auth }; + this.subject.next(this.wsSendWrapper(UserOperation.GetPost, data)); } public getCommunity(communityId: number) { @@ -59,6 +60,11 @@ export class WebSocketService { this.subject.next(this.wsSendWrapper(UserOperation.CreateComment, commentForm)); } + public likeComment(form: CommentLikeForm) { + this.setAuth(form); + this.subject.next(this.wsSendWrapper(UserOperation.CreateCommentLike, form)); + } + private wsSendWrapper(op: UserOperation, data: any) { let send = { op: UserOperation[op], data: data }; console.log(send); @@ -72,4 +78,10 @@ export class WebSocketService { throw "Not logged in"; } } + } + +window.onbeforeunload = (e => { + WebSocketService.Instance.subject.unsubscribe(); +}); + |