} from '../interfaces';
import { Subscription } from 'rxjs';
import {
+ wsJsonToRes,
capitalizeFirstLetter,
mentionDropdownFetchLimit,
- msgOp,
mdToHtml,
randomStr,
markdownHelpUrl,
this.userSub = WebSocketService.Instance.subject.subscribe(
msg => {
- let op: UserOperation = msgOp(msg);
- if (op == UserOperation.Search) {
- let res: SearchResponse = msg;
- let users = res.users.map(u => {
+ let res = wsJsonToRes(msg);
+ if (res.op == UserOperation.Search) {
+ let data = res.data as SearchResponse;
+ let users = data.users.map(u => {
return { key: u.name };
});
cb(users);
this.communitySub = WebSocketService.Instance.subject.subscribe(
msg => {
- let op: UserOperation = msgOp(msg);
- if (op == UserOperation.Search) {
- let res: SearchResponse = msg;
- let communities = res.communities.map(u => {
+ let res = wsJsonToRes(msg);
+ if (res.op == UserOperation.Search) {
+ let data = res.data as SearchResponse;
+ let communities = data.communities.map(u => {
return { key: u.name };
});
cb(communities);
FollowCommunityForm,
ListCommunitiesForm,
SortType,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService } from '../services';
import { wsJsonToRes } from '../utils';
WebSocketService.Instance.listCommunities(listCommunitiesForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
i.props.onCancel();
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
console.log(msg);
if (res.error) {
ListingType,
GetPostsResponse,
CreatePostLikeResponse,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { PostListings } from './post-listings';
WebSocketService.Instance.getPosts(getPostsForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
GetUserMentionsResponse,
UserMentionResponse,
CommentResponse,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { wsJsonToRes, fetchLimit } from '../utils';
WebSocketService.Instance.markAllAsRead();
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
UserOperation,
PasswordResetForm,
GetSiteResponse,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { wsJsonToRes, validEmail } from '../utils';
WebSocketService.Instance.passwordReset(resetForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
if (res.error) {
alert(i18n.t(res.error));
CreatePostLikeResponse,
Post,
GetPostsForm,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { PostListings } from './post-listings';
WebSocketService.Instance.getPosts(getPostsForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
WebSocketService.Instance.getModlog(modlogForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
import { Component } from 'inferno';
-import * as moment from 'moment';
+import moment from 'moment';
import { getMomentLanguage } from '../utils';
import { i18n } from '../i18next';
SortType,
GetSiteResponse,
Comment,
+ WebSocketJsonResponse,
} from '../interfaces';
import {
wsJsonToRes,
i.setState(i.state);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
if (res.error) {
if (res.error == 'not_logged_in') {
UserOperation,
LoginResponse,
PasswordChangeForm,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { wsJsonToRes, capitalizeFirstLetter } from '../utils';
WebSocketService.Instance.passwordChange(i.state.passwordChangeForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
if (msg.error) {
alert(i18n.t(msg.error));
SearchType,
SearchResponse,
GetSiteResponse,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
});
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
if (res.error) {
alert(i18n.t(res.error));
SearchResponse,
GetSiteResponse,
GetCommunityResponse,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { wsJsonToRes, hotRank } from '../utils';
);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
SearchForm,
SearchResponse,
SearchType,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService } from '../services';
import {
);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
import { Component, linkEvent } from 'inferno';
import { Subscription } from 'rxjs';
import { retryWhen, delay, take } from 'rxjs/operators';
-import { RegisterForm, LoginResponse, UserOperation } from '../interfaces';
+import {
+ RegisterForm,
+ LoginResponse,
+ UserOperation,
+ WebSocketJsonResponse,
+} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { wsJsonToRes } from '../utils';
import { SiteForm } from './site-form';
i.setState(i.state);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
let res = wsJsonToRes(msg);
if (res.error) {
alert(i18n.t(res.error));
BanUserResponse,
AddAdminResponse,
DeleteAccountForm,
+ WebSocketJsonResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
WebSocketService.Instance.deleteAccount(i.state.deleteAccountForm);
}
- parseMessage(msg: any) {
+ parseMessage(msg: WebSocketJsonResponse) {
console.log(msg);
let res = wsJsonToRes(msg);
if (res.error) {
data: ResponseType;
error?: string;
}
+
+export interface WebSocketJsonResponse {
+ op: string;
+ data: ResponseType;
+ error?: string;
+}
ListingType,
SearchType,
WebSocketResponse,
+ WebSocketJsonResponse,
} from './interfaces';
import { UserService } from './services/UserService';
import markdown_it from 'markdown-it';
.substr(2, 10);
}
-export function wsJsonToRes(msg: any): WebSocketResponse {
+export function wsJsonToRes(msg: WebSocketJsonResponse): WebSocketResponse {
let opStr: string = msg.op;
return {
op: UserOperation[opStr],