summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/inbox.tsx2
-rw-r--r--ui/src/components/navbar.tsx8
-rw-r--r--ui/src/components/post.tsx4
3 files changed, 10 insertions, 4 deletions
diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx
index 027a1db0..56bf1578 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -443,9 +443,9 @@ export class Inbox extends Component<any, InboxState> {
this.state.messages.filter(
r => !r.read && r.creator_id !== UserService.Instance.user.id
).length;
+ UserService.Instance.user.unreadCount = count;
UserService.Instance.sub.next({
user: UserService.Instance.user,
- unreadCount: count,
});
}
}
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx
index c675cfe7..75cdd554 100644
--- a/ui/src/components/navbar.tsx
+++ b/ui/src/components/navbar.tsx
@@ -60,8 +60,10 @@ export class Navbar extends Component<any, NavbarState> {
// Subscribe to user changes
this.userSub = UserService.Instance.sub.subscribe(user => {
this.state.isLoggedIn = user.user !== undefined;
- this.state.unreadCount = user.unreadCount;
- this.requestNotificationPermission();
+ if (this.state.isLoggedIn) {
+ this.state.unreadCount = user.user.unreadCount;
+ this.requestNotificationPermission();
+ }
this.setState(this.state);
});
@@ -304,9 +306,9 @@ export class Navbar extends Component<any, NavbarState> {
}
sendUnreadCount() {
+ UserService.Instance.user.unreadCount = this.state.unreadCount;
UserService.Instance.sub.next({
user: UserService.Instance.user,
- unreadCount: this.state.unreadCount,
});
}
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index b5b1fce3..d8f662cf 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -156,6 +156,10 @@ export class Post extends Component<any, PostState> {
auth: null,
};
WebSocketService.Instance.editComment(form);
+ UserService.Instance.user.unreadCount--;
+ UserService.Instance.sub.next({
+ user: UserService.Instance.user,
+ });
}
}