summaryrefslogtreecommitdiffstats
path: root/ui/src/components/inbox.tsx
diff options
context:
space:
mode:
authorDessalines <dessalines@users.noreply.github.com>2020-07-09 20:03:33 -0400
committerGitHub <noreply@github.com>2020-07-09 20:03:33 -0400
commit85c07e7154c82e5b387bb6a02aae70645cf1d8e0 (patch)
tree3b5a56578b8b504faf366555466422f0b14b2770 /ui/src/components/inbox.tsx
parentd222c60cef289b57f0ce350e9f24ce2df4792ef5 (diff)
Correctly hide next / prev in paginators. Fixes #914 (#927)
Diffstat (limited to 'ui/src/components/inbox.tsx')
-rw-r--r--ui/src/components/inbox.tsx30
1 files changed, 18 insertions, 12 deletions
diff --git a/ui/src/components/inbox.tsx b/ui/src/components/inbox.tsx
index a88d45c5..2bf1fb47 100644
--- a/ui/src/components/inbox.tsx
+++ b/ui/src/components/inbox.tsx
@@ -329,12 +329,14 @@ export class Inbox extends Component<any, InboxState> {
{i18n.t('prev')}
</button>
)}
- <button
- class="btn btn-sm btn-secondary"
- onClick={linkEvent(this, this.nextPage)}
- >
- {i18n.t('next')}
- </button>
+ {this.unreadCount() > 0 && (
+ <button
+ class="btn btn-sm btn-secondary"
+ onClick={linkEvent(this, this.nextPage)}
+ >
+ {i18n.t('next')}
+ </button>
+ )}
</div>
);
}
@@ -534,15 +536,19 @@ export class Inbox extends Component<any, InboxState> {
}
sendUnreadCount() {
- let count =
+ UserService.Instance.user.unreadCount = this.unreadCount();
+ UserService.Instance.sub.next({
+ user: UserService.Instance.user,
+ });
+ }
+
+ unreadCount(): number {
+ return (
this.state.replies.filter(r => !r.read).length +
this.state.mentions.filter(r => !r.read).length +
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,
- });
+ ).length
+ );
}
}