|
|
@ -9,9 +9,12 @@ import {
|
|
|
|
CommentForm,
|
|
|
|
CommentForm,
|
|
|
|
SaveCommentForm,
|
|
|
|
SaveCommentForm,
|
|
|
|
CommentLikeForm,
|
|
|
|
CommentLikeForm,
|
|
|
|
|
|
|
|
GetPostForm,
|
|
|
|
GetPostsForm,
|
|
|
|
GetPostsForm,
|
|
|
|
CreatePostLikeForm,
|
|
|
|
CreatePostLikeForm,
|
|
|
|
|
|
|
|
GetCommunityForm,
|
|
|
|
FollowCommunityForm,
|
|
|
|
FollowCommunityForm,
|
|
|
|
|
|
|
|
GetFollowedCommunitiesForm,
|
|
|
|
GetUserDetailsForm,
|
|
|
|
GetUserDetailsForm,
|
|
|
|
ListCommunitiesForm,
|
|
|
|
ListCommunitiesForm,
|
|
|
|
GetModlogForm,
|
|
|
|
GetModlogForm,
|
|
|
@ -35,6 +38,7 @@ import {
|
|
|
|
PrivateMessageForm,
|
|
|
|
PrivateMessageForm,
|
|
|
|
EditPrivateMessageForm,
|
|
|
|
EditPrivateMessageForm,
|
|
|
|
GetPrivateMessagesForm,
|
|
|
|
GetPrivateMessagesForm,
|
|
|
|
|
|
|
|
MessageType,
|
|
|
|
} from '../interfaces';
|
|
|
|
} from '../interfaces';
|
|
|
|
import { webSocket } from 'rxjs/webSocket';
|
|
|
|
import { webSocket } from 'rxjs/webSocket';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
|
import { Subject } from 'rxjs';
|
|
|
@ -108,9 +112,9 @@ export class WebSocketService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getFollowedCommunities() {
|
|
|
|
public getFollowedCommunities() {
|
|
|
|
let data = { auth: UserService.Instance.auth };
|
|
|
|
let form: GetFollowedCommunitiesForm = { auth: UserService.Instance.auth };
|
|
|
|
this.subject.next(
|
|
|
|
this.subject.next(
|
|
|
|
this.wsSendWrapper(UserOperation.GetFollowedCommunities, data)
|
|
|
|
this.wsSendWrapper(UserOperation.GetFollowedCommunities, form)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -125,19 +129,14 @@ export class WebSocketService {
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.CreatePost, postForm));
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.CreatePost, postForm));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getPost(postId: number) {
|
|
|
|
public getPost(form: GetPostForm) {
|
|
|
|
let data = { id: postId, auth: UserService.Instance.auth };
|
|
|
|
this.setAuth(form);
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.GetPost, data));
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.GetPost, form));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getCommunity(communityId: number) {
|
|
|
|
|
|
|
|
let data = { id: communityId, auth: UserService.Instance.auth };
|
|
|
|
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getCommunityByName(name: string) {
|
|
|
|
public getCommunity(form: GetCommunityForm) {
|
|
|
|
let data = { name: name, auth: UserService.Instance.auth };
|
|
|
|
this.setAuth(form);
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, data));
|
|
|
|
this.subject.next(this.wsSendWrapper(UserOperation.GetCommunity, form));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public createComment(commentForm: CommentForm) {
|
|
|
|
public createComment(commentForm: CommentForm) {
|
|
|
@ -310,7 +309,7 @@ export class WebSocketService {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private wsSendWrapper(op: UserOperation, data: any) {
|
|
|
|
private wsSendWrapper(op: UserOperation, data: MessageType) {
|
|
|
|
let send = { op: UserOperation[op], data: data };
|
|
|
|
let send = { op: UserOperation[op], data: data };
|
|
|
|
console.log(send);
|
|
|
|
console.log(send);
|
|
|
|
return send;
|
|
|
|
return send;
|
|
|
|