Fixed websockets in navigation
This commit is contained in:
@@ -54,15 +54,24 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['menu', 'user', 'menuNeedsUpdate']),
|
||||
...mapGetters(['menu', 'user', 'menuNeedsUpdate', 'socket']),
|
||||
},
|
||||
watch: {
|
||||
menuNeedsUpdate(newValue) {
|
||||
if (newValue) {
|
||||
console.log('Menu needs update, loading menu...');
|
||||
this.loadMenu();
|
||||
}
|
||||
},
|
||||
socket(newValue) {
|
||||
if (newValue) {
|
||||
newValue.on('forumschanged', (data) => {
|
||||
this.fetchForums();
|
||||
});
|
||||
newValue.on('friendloginchanged', () => {
|
||||
this.fetchFriends();
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.user && this.user.id) {
|
||||
@@ -75,10 +84,12 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
if (this.$store.getters.socket) {
|
||||
console.log('connect sockets in navigation')
|
||||
this.$store.getters.socket.on('forumschanged', (data) => {
|
||||
this.fetchForums();
|
||||
});
|
||||
this.$store.getters.socket.on('friendloginchanged', () => {
|
||||
console.log('update friends');
|
||||
this.fetchFriends();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user