diff options
author | Dessalines <tyhou13@gmx.com> | 2019-05-19 09:15:08 -0700 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2019-05-19 09:15:08 -0700 |
commit | 1b6ddb869ceca51dbd6ea92457738d0f9846796d (patch) | |
tree | 9e2b78375daf54fb31108aec7a1a3a7fe1bf860b /ui/src/components/navbar.tsx | |
parent | d1fee01c6a9675ed24b5d37bd1738d5eb770d511 (diff) |
Mark as read if viewing link.
- Fixes #154. #153
Diffstat (limited to 'ui/src/components/navbar.tsx')
-rw-r--r-- | ui/src/components/navbar.tsx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ui/src/components/navbar.tsx b/ui/src/components/navbar.tsx index c19c2084..68e486c1 100644 --- a/ui/src/components/navbar.tsx +++ b/ui/src/components/navbar.tsx @@ -12,6 +12,7 @@ interface NavbarState { expanded: boolean; expandUserDropdown: boolean; replies: Array<Comment>, + fetchCount: number, unreadCount: number; siteName: string; } @@ -22,6 +23,7 @@ export class Navbar extends Component<any, NavbarState> { emptyState: NavbarState = { isLoggedIn: (UserService.Instance.user !== undefined), unreadCount: 0, + fetchCount: 0, replies: [], expanded: false, expandUserDropdown: false, @@ -158,12 +160,13 @@ export class Navbar extends Component<any, NavbarState> { return; } else if (op == UserOperation.GetReplies) { let res: GetRepliesResponse = msg; - if (res.replies.length > 0 && this.state.replies.length > 0 && - (JSON.stringify(this.state.replies) !== JSON.stringify(res.replies))) { - this.notify(res.replies); + let unreadReplies = res.replies.filter(r => !r.read); + if (unreadReplies.length > 0 && this.state.fetchCount > 1 && + (JSON.stringify(this.state.replies) !== JSON.stringify(unreadReplies))) { + this.notify(unreadReplies); } - this.state.replies = res.replies; + this.state.replies = unreadReplies; this.sendRepliesCount(res); } else if (op == UserOperation.GetSite) { let res: GetSiteResponse = msg; @@ -190,6 +193,7 @@ export class Navbar extends Component<any, NavbarState> { limit: 9999, }; WebSocketService.Instance.getReplies(repliesForm); + this.state.fetchCount++; } } @@ -222,7 +226,7 @@ export class Navbar extends Component<any, NavbarState> { else { var notification = new Notification(`${replies.length} Unread Messages`, { icon: `${window.location.protocol}//${window.location.host}/static/assets/apple-touch-icon.png`, - body: recentReply.content + body: `${recentReply.creator_name}: ${recentReply.content}` }); notification.onclick = () => { |