diff --git a/src/client/app/desktop/views/components/ui.header.nav.vue b/src/client/app/desktop/views/components/ui.header.nav.vue index 201b04b039..4780c57cb4 100644 --- a/src/client/app/desktop/views/components/ui.header.nav.vue +++ b/src/client/app/desktop/views/components/ui.header.nav.vue @@ -12,7 +12,7 @@ %fa:comments%

%i18n:@messaging%

- +
  • @@ -35,48 +35,33 @@ import MkGameWindow from './game-window.vue'; export default Vue.extend({ data() { return { - hasUnreadMessagingMessages: false, hasGameInvitations: false, connection: null, connectionId: null }; }, + computed: { + hasUnreadMessagingMessage(): boolean { + return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadMessagingMessage; + } + }, mounted() { if (this.$store.getters.isSignedIn) { this.connection = (this as any).os.stream.getConnection(); this.connectionId = (this as any).os.stream.use(); - this.connection.on('read_all_messaging_messages', this.onReadAllMessagingMessages); - this.connection.on('unread_messaging_message', this.onUnreadMessagingMessage); this.connection.on('othello_invited', this.onOthelloInvited); this.connection.on('othello_no_invites', this.onOthelloNoInvites); - - // Fetch count of unread messaging messages - (this as any).api('messaging/unread').then(res => { - if (res.count > 0) { - this.hasUnreadMessagingMessages = true; - } - }); } }, beforeDestroy() { if (this.$store.getters.isSignedIn) { - this.connection.off('read_all_messaging_messages', this.onReadAllMessagingMessages); - this.connection.off('unread_messaging_message', this.onUnreadMessagingMessage); this.connection.off('othello_invited', this.onOthelloInvited); this.connection.off('othello_no_invites', this.onOthelloNoInvites); (this as any).os.stream.dispose(this.connectionId); } }, methods: { - onUnreadMessagingMessage() { - this.hasUnreadMessagingMessages = true; - }, - - onReadAllMessagingMessages() { - this.hasUnreadMessagingMessages = false; - }, - onOthelloInvited() { this.hasGameInvitations = true; },