summaryrefslogtreecommitdiffstats
path: root/ui/src/components/navbar.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-18 23:54:10 -0500
committerDessalines <tyhou13@gmx.com>2020-01-18 23:54:10 -0500
commita044718066623f19d51196d444bd199c1231cebe (patch)
treecbffb18d826df1330ce2b7f1a814205ba45148d1 /ui/src/components/navbar.tsx
parent05ee5a8b600fdd7a64ad66bb52978befed3a7614 (diff)
First pass at fixing UI to work with new websocketresponses.
Diffstat (limited to 'ui/src/components/navbar.tsx')
-rw-r--r--ui/src/components/navbar.tsx30
1 files changed, 15 insertions, 15 deletions
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx
index 9fa1e3dc..50bf19c7 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -14,7 +14,7 @@ import {
Comment,
} from '../interfaces';
import {
- msgOp,
+ wsJsonToRes,
pictshareAvatarThumbnail,
showAvatars,
fetchLimit,
@@ -182,16 +182,16 @@ export class Navbar extends Component<any, NavbarState> {
}
parseMessage(msg: any) {
- let op: UserOperation = msgOp(msg);
- if (msg.error) {
- if (msg.error == 'not_logged_in') {
+ let res = wsJsonToRes(msg);
+ if (res.error) {
+ if (res.error == 'not_logged_in') {
UserService.Instance.logout();
location.reload();
}
return;
- } else if (op == UserOperation.GetReplies) {
- let res: GetRepliesResponse = msg;
- let unreadReplies = res.replies.filter(r => !r.read);
+ } else if (res.op == UserOperation.GetReplies) {
+ let data = res.data as GetRepliesResponse;
+ let unreadReplies = data.replies.filter(r => !r.read);
if (
unreadReplies.length > 0 &&
this.state.fetchCount > 1 &&
@@ -203,9 +203,9 @@ export class Navbar extends Component<any, NavbarState> {
this.state.replies = unreadReplies;
this.setState(this.state);
this.sendUnreadCount();
- } else if (op == UserOperation.GetUserMentions) {
- let res: GetUserMentionsResponse = msg;
- let unreadMentions = res.mentions.filter(r => !r.read);
+ } else if (res.op == UserOperation.GetUserMentions) {
+ let data = res.data as GetUserMentionsResponse;
+ let unreadMentions = data.mentions.filter(r => !r.read);
if (
unreadMentions.length > 0 &&
this.state.fetchCount > 1 &&
@@ -217,12 +217,12 @@ export class Navbar extends Component<any, NavbarState> {
this.state.mentions = unreadMentions;
this.setState(this.state);
this.sendUnreadCount();
- } else if (op == UserOperation.GetSite) {
- let res: GetSiteResponse = msg;
+ } else if (res.op == UserOperation.GetSite) {
+ let data = res.data as GetSiteResponse;
- if (res.site) {
- this.state.siteName = res.site.name;
- WebSocketService.Instance.site = res.site;
+ if (data.site) {
+ this.state.siteName = data.site.name;
+ WebSocketService.Instance.site = data.site;
this.setState(this.state);
}
}