Starting to work on websocket scopes.

pull/722/head
Dessalines 2020-01-26 12:23:28 -05:00
parent 29d34eaf03
commit 65adb0d15d
3 changed files with 10 additions and 0 deletions

View File

@ -41,6 +41,7 @@ export enum UserOperation {
CreatePrivateMessage, CreatePrivateMessage,
EditPrivateMessage, EditPrivateMessage,
GetPrivateMessages, GetPrivateMessages,
UserJoin,
} }
export enum CommentSortType { export enum CommentSortType {

View File

@ -49,6 +49,7 @@ export class UserService {
console.log(this.user); console.log(this.user);
} }
// TODO find all refs to this, make sure everything is well typed
public static get Instance() { public static get Instance() {
return this._instance || (this._instance = new this()); return this._instance || (this._instance = new this());
} }

View File

@ -67,12 +67,19 @@ export class WebSocketService {
.subscribe(); .subscribe();
console.log(`Connected to ${wsUri}`); console.log(`Connected to ${wsUri}`);
if (UserService.Instance.user) {
}
} }
public static get Instance() { public static get Instance() {
return this._instance || (this._instance = new this()); return this._instance || (this._instance = new this());
} }
public userJoin() {
this.wsSendWrapper(UserOperation.ListCategories, undefined);
}
public login(loginForm: LoginForm) { public login(loginForm: LoginForm) {
this.subject.next(this.wsSendWrapper(UserOperation.Login, loginForm)); this.subject.next(this.wsSendWrapper(UserOperation.Login, loginForm));
} }
@ -125,6 +132,7 @@ export class WebSocketService {
this.subject.next(this.wsSendWrapper(UserOperation.CreatePost, postForm)); this.subject.next(this.wsSendWrapper(UserOperation.CreatePost, postForm));
} }
// TODO strictly type these
public getPost(postId: number) { public getPost(postId: number) {
let data = { id: postId, auth: UserService.Instance.auth }; let data = { id: postId, auth: UserService.Instance.auth };
this.subject.next(this.wsSendWrapper(UserOperation.GetPost, data)); this.subject.next(this.wsSendWrapper(UserOperation.GetPost, data));