summaryrefslogtreecommitdiffstats
path: root/ui/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/services')
-rw-r--r--ui/src/services/WebSocketService.ts16
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();
+});
+