mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-25 12:21:31 +00:00
Starting to work on websocket scopes.
This commit is contained in:
parent
7468df649e
commit
3df34acdcf
3 changed files with 10 additions and 0 deletions
1
ui/src/interfaces.ts
vendored
1
ui/src/interfaces.ts
vendored
|
@ -41,6 +41,7 @@ export enum UserOperation {
|
|||
CreatePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPrivateMessages,
|
||||
UserJoin,
|
||||
}
|
||||
|
||||
export enum CommentSortType {
|
||||
|
|
1
ui/src/services/UserService.ts
vendored
1
ui/src/services/UserService.ts
vendored
|
@ -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());
|
||||
}
|
||||
|
|
8
ui/src/services/WebSocketService.ts
vendored
8
ui/src/services/WebSocketService.ts
vendored
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue