summaryrefslogtreecommitdiffstats
path: root/ui/src/services
diff options
context:
space:
mode:
authorDessalines <happydooby@gmail.com>2019-04-02 23:49:32 -0700
committerDessalines <happydooby@gmail.com>2019-04-02 23:49:32 -0700
commitba5c93c8da599c0697883b3bd1673a584660ea34 (patch)
tree26a8754f8ca377efeff8446c2f660ed3d4fdfd50 /ui/src/services
parentd443b048860ea302cfec2c674ba0a9838afe2b28 (diff)
Adding forum / community pages
- Adding main forum page. Fixes #11 - Adding view version for posts. #21 - Got rid of fedi user ids. Fixes #22 - Post sorting working. Fixes #24
Diffstat (limited to 'ui/src/services')
-rw-r--r--ui/src/services/WebSocketService.ts16
1 files changed, 13 insertions, 3 deletions
diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts
index 1ea207f4..04376ff8 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, CommentLikeForm } from '../interfaces';
+import { LoginForm, RegisterForm, UserOperation, CommunityForm, PostForm, CommentForm, CommentLikeForm, GetListingsForm, CreatePostLikeForm } from '../interfaces';
import { webSocket } from 'rxjs/webSocket';
import { Subject } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
@@ -70,15 +70,25 @@ export class WebSocketService {
this.subject.next(this.wsSendWrapper(UserOperation.CreateCommentLike, form));
}
+ public getPosts(form: GetListingsForm) {
+ this.setAuth(form, false);
+ this.subject.next(this.wsSendWrapper(UserOperation.GetPosts, form));
+ }
+
+ public likePost(form: CreatePostLikeForm) {
+ this.setAuth(form);
+ this.subject.next(this.wsSendWrapper(UserOperation.CreatePostLike, form));
+ }
+
private wsSendWrapper(op: UserOperation, data: any) {
let send = { op: UserOperation[op], data: data };
console.log(send);
return send;
}
- private setAuth(obj: any) {
+ private setAuth(obj: any, throwErr: boolean = true) {
obj.auth = UserService.Instance.auth;
- if (obj.auth == null) {
+ if (obj.auth == null && throwErr) {
alert("Not logged in.");
throw "Not logged in";
}