From ab16fb3a3fff96a4fa2bc1fc0e56a87c129a4625 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 May 2018 01:22:39 +0900 Subject: #1634 --- .../app/mobile/views/components/ui.header.vue | 52 +++++----------------- src/client/app/mobile/views/components/ui.nav.vue | 52 +++++----------------- 2 files changed, 24 insertions(+), 80 deletions(-) (limited to 'src/client/app/mobile') diff --git a/src/client/app/mobile/views/components/ui.header.vue b/src/client/app/mobile/views/components/ui.header.vue index 09aa18f769..c72b15fb8b 100644 --- a/src/client/app/mobile/views/components/ui.header.vue +++ b/src/client/app/mobile/views/components/ui.header.vue @@ -6,7 +6,7 @@

おかえりなさい、{{ $store.state.i | userName }}さん

- +

Misskey

@@ -25,13 +25,19 @@ export default Vue.extend({ props: ['func'], data() { return { - hasUnreadNotifications: false, - hasUnreadMessagingMessages: false, - hasGameInvitations: false, + hasGameInvitation: false, connection: null, connectionId: null }; }, + computed: { + hasUnreadNotification(): boolean { + return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadNotification; + }, + hasUnreadMessagingMessage(): boolean { + return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadMessagingMessage; + } + }, mounted() { this.$store.commit('setUiHeaderHeight', 48); @@ -39,27 +45,9 @@ export default Vue.extend({ this.connection = (this as any).os.stream.getConnection(); this.connectionId = (this as any).os.stream.use(); - this.connection.on('read_all_notifications', this.onReadAllNotifications); - this.connection.on('unread_notification', this.onUnreadNotification); - 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 notifications - (this as any).api('notifications/get_unread_count').then(res => { - if (res.count > 0) { - this.hasUnreadNotifications = true; - } - }); - - // Fetch count of unread messaging messages - (this as any).api('messaging/unread').then(res => { - if (res.count > 0) { - this.hasUnreadMessagingMessages = true; - } - }); - const ago = (new Date().getTime() - new Date(this.$store.state.i.lastUsedAt).getTime()) / 1000; const isHisasiburi = ago >= 3600; this.$store.state.i.lastUsedAt = new Date(); @@ -110,33 +98,17 @@ export default Vue.extend({ }, beforeDestroy() { if (this.$store.getters.isSignedIn) { - this.connection.off('read_all_notifications', this.onReadAllNotifications); - this.connection.off('unread_notification', this.onUnreadNotification); - 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: { - onReadAllNotifications() { - this.hasUnreadNotifications = false; - }, - onUnreadNotification() { - this.hasUnreadNotifications = true; - }, - onReadAllMessagingMessages() { - this.hasUnreadMessagingMessages = false; - }, - onUnreadMessagingMessage() { - this.hasUnreadMessagingMessages = true; - }, onOthelloInvited() { - this.hasGameInvitations = true; + this.hasGameInvitation = true; }, onOthelloNoInvites() { - this.hasGameInvitations = false; + this.hasGameInvitation = false; } } }); diff --git a/src/client/app/mobile/views/components/ui.nav.vue b/src/client/app/mobile/views/components/ui.nav.vue index 5f0cc831cc..de8c21e795 100644 --- a/src/client/app/mobile/views/components/ui.nav.vue +++ b/src/client/app/mobile/views/components/ui.nav.vue @@ -16,7 +16,7 @@