summaryrefslogtreecommitdiffstats
path: root/ui/src/services
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-30 21:15:58 -0500
committerDessalines <tyhou13@gmx.com>2020-01-30 21:15:58 -0500
commit5188bddd4ddb1d4f4bc4add24db210789054c2a5 (patch)
treef68f8cebb4189acb591bbd129fa052b1d09619d6 /ui/src/services
parent65adb0d15dcb10382dadca2694ee17b206c384fd (diff)
parent8cbdba1da39c15d2a3d13919398fc4d4c8ef2c6c (diff)
Merge branch 'dev' into websocket_scopes
Diffstat (limited to 'ui/src/services')
-rw-r--r--ui/src/services/WebSocketService.ts28
1 files changed, 13 insertions, 15 deletions
diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts
index 7b338c60..3ad0de44 100644
--- a/ui/src/services/WebSocketService.ts
+++ b/ui/src/services/WebSocketService.ts
@@ -9,9 +9,12 @@ import {
CommentForm,
SaveCommentForm,
CommentLikeForm,
+ GetPostForm,
GetPostsForm,
CreatePostLikeForm,
+ GetCommunityForm,
FollowCommunityForm,
+ GetFollowedCommunitiesForm,
GetUserDetailsForm,
ListCommunitiesForm,
GetModlogForm,
@@ -35,6 +38,7 @@ import {
PrivateMessageForm,
EditPrivateMessageForm,
GetPrivateMessagesForm,
+ MessageType,
} from '../interfaces';
import { webSocket } from 'rxjs/webSocket';
import { Subject } from 'rxjs';
@@ -115,9 +119,9 @@ export class WebSocketService {
}
public getFollowedCommunities() {
- let data = { auth: UserService.Instance.auth };
+ let form: GetFollowedCommunitiesForm = { auth: UserService.Instance.auth };
this.subject.next(
- this.wsSendWrapper(UserOperation.GetFollowedCommunities, data)
+ this.wsSendWrapper(UserOperation.GetFollowedCommunities, form)
);
}
@@ -132,20 +136,14 @@ export class WebSocketService {
this.subject.next(this.wsSendWrapper(UserOperation.CreatePost, postForm));
}
- // TODO strictly type these
- public getPost(postId: number) {
- let data = { id: postId, auth: UserService.Instance.auth };
- this.subject.next(this.wsSendWrapper(UserOperation.GetPost, data));
- }
-
- public getCommunity(communityId: number) {
- let data = { id: communityId, auth: UserService.Instance.auth };
- this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
+ public getPost(form: GetPostForm) {
+ this.setAuth(form, false);
+ this.subject.next(this.wsSendWrapper(UserOperation.GetPost, form));
}
- public getCommunityByName(name: string) {
- let data = { name: name, auth: UserService.Instance.auth };
- this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
+ public getCommunity(form: GetCommunityForm) {
+ this.setAuth(form, false);
+ this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, form));
}
public createComment(commentForm: CommentForm) {
@@ -318,7 +316,7 @@ export class WebSocketService {
);
}
- private wsSendWrapper(op: UserOperation, data: any) {
+ private wsSendWrapper(op: UserOperation, data: MessageType) {
let send = { op: UserOperation[op], data: data };
console.log(send);
return send;