mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-12 21:58:58 +09:00
Fix bug
This commit is contained in:
parent
9f1385b03a
commit
9d27fa7eaa
@ -12,7 +12,7 @@
|
||||
<a @click="messaging">
|
||||
%fa:comments%
|
||||
<p>%i18n:@messaging%</p>
|
||||
<template v-if="hasUnreadMessagingMessages">%fa:circle%</template>
|
||||
<template v-if="hasUnreadMessagingMessage">%fa:circle%</template>
|
||||
</a>
|
||||
</li>
|
||||
<li class="game">
|
||||
@ -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;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user