Fixed websockets in navigation

This commit is contained in:
Torsten Schulz
2024-12-04 22:51:04 +01:00
parent 069c97fa90
commit 8c15fb7f2b
9 changed files with 61 additions and 34 deletions

View File

@@ -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();
});
}