From 9d27fa7eaa8ce80233f333b24e093fc39ffb1d2a Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 May 2018 02:31:32 +0900 Subject: [PATCH] Fix bug --- .../views/components/ui.header.nav.vue | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) 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 201b04b03..4780c57cb 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; },