From 3df34acdcf0407160fc8d55b3c7196e43215e936 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 26 Jan 2020 12:23:28 -0500 Subject: [PATCH] Starting to work on websocket scopes. --- ui/src/interfaces.ts | 1 + ui/src/services/UserService.ts | 1 + ui/src/services/WebSocketService.ts | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index cd3961b5..5022d817 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -41,6 +41,7 @@ export enum UserOperation { CreatePrivateMessage, EditPrivateMessage, GetPrivateMessages, + UserJoin, } export enum CommentSortType { diff --git a/ui/src/services/UserService.ts b/ui/src/services/UserService.ts index 03380e59..0c3325a0 100644 --- a/ui/src/services/UserService.ts +++ b/ui/src/services/UserService.ts @@ -49,6 +49,7 @@ export class UserService { console.log(this.user); } + // TODO find all refs to this, make sure everything is well typed public static get Instance() { return this._instance || (this._instance = new this()); } diff --git a/ui/src/services/WebSocketService.ts b/ui/src/services/WebSocketService.ts index e72a2871..7b338c60 100644 --- a/ui/src/services/WebSocketService.ts +++ b/ui/src/services/WebSocketService.ts @@ -67,12 +67,19 @@ export class WebSocketService { .subscribe(); console.log(`Connected to ${wsUri}`); + + if (UserService.Instance.user) { + } } public static get Instance() { return this._instance || (this._instance = new this()); } + public userJoin() { + this.wsSendWrapper(UserOperation.ListCategories, undefined); + } + public login(loginForm: LoginForm) { this.subject.next(this.wsSendWrapper(UserOperation.Login, loginForm)); } @@ -125,6 +132,7 @@ 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));