Fix bug
This commit is contained in:
parent
9f1385b03a
commit
9d27fa7eaa
@ -12,7 +12,7 @@
|
|||||||
<a @click="messaging">
|
<a @click="messaging">
|
||||||
%fa:comments%
|
%fa:comments%
|
||||||
<p>%i18n:@messaging%</p>
|
<p>%i18n:@messaging%</p>
|
||||||
<template v-if="hasUnreadMessagingMessages">%fa:circle%</template>
|
<template v-if="hasUnreadMessagingMessage">%fa:circle%</template>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="game">
|
<li class="game">
|
||||||
@ -35,48 +35,33 @@ import MkGameWindow from './game-window.vue';
|
|||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hasUnreadMessagingMessages: false,
|
|
||||||
hasGameInvitations: false,
|
hasGameInvitations: false,
|
||||||
connection: null,
|
connection: null,
|
||||||
connectionId: null
|
connectionId: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
hasUnreadMessagingMessage(): boolean {
|
||||||
|
return this.$store.getters.isSignedIn && this.$store.state.i.hasUnreadMessagingMessage;
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$store.getters.isSignedIn) {
|
if (this.$store.getters.isSignedIn) {
|
||||||
this.connection = (this as any).os.stream.getConnection();
|
this.connection = (this as any).os.stream.getConnection();
|
||||||
this.connectionId = (this as any).os.stream.use();
|
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_invited', this.onOthelloInvited);
|
||||||
this.connection.on('othello_no_invites', this.onOthelloNoInvites);
|
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() {
|
beforeDestroy() {
|
||||||
if (this.$store.getters.isSignedIn) {
|
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_invited', this.onOthelloInvited);
|
||||||
this.connection.off('othello_no_invites', this.onOthelloNoInvites);
|
this.connection.off('othello_no_invites', this.onOthelloNoInvites);
|
||||||
(this as any).os.stream.dispose(this.connectionId);
|
(this as any).os.stream.dispose(this.connectionId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onUnreadMessagingMessage() {
|
|
||||||
this.hasUnreadMessagingMessages = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
onReadAllMessagingMessages() {
|
|
||||||
this.hasUnreadMessagingMessages = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
onOthelloInvited() {
|
onOthelloInvited() {
|
||||||
this.hasGameInvitations = true;
|
this.hasGameInvitations = true;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user