Browse Source

fix(WS): on socket reconnect, rooms should be rejoined

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 3 years ago
parent
commit
20a0c887f2

+ 0 - 2
backend/logic/ws.js

@@ -289,8 +289,6 @@ class _WSModule extends CoreClass {
 					return resolve();
 				});
 
-			console.log("room doesn't exist");
-
 			return resolve();
 		});
 	}

+ 8 - 4
frontend/src/pages/Profile/tabs/Playlists.vue

@@ -92,6 +92,8 @@
 import draggable from "vuedraggable";
 import { mapActions, mapState, mapGetters } from "vuex";
 
+import ws from "../../../ws";
+
 import SortablePlaylists from "../../../mixins/SortablePlaylists.vue";
 import PlaylistItem from "../../../components/ui/PlaylistItem.vue";
 
@@ -137,10 +139,12 @@ export default {
 			this.tab = this.$route.query.tab;
 
 		if (this.myUserId !== this.userId) {
-			this.socket.dispatch(
-				"apis.joinRoom",
-				`profile-${this.userId}-playlists`,
-				() => {}
+			ws.onConnect(() =>
+				this.socket.dispatch(
+					"apis.joinRoom",
+					`profile-${this.userId}-playlists`,
+					() => {}
+				)
 			);
 		}
 

+ 10 - 6
frontend/src/pages/Profile/tabs/RecentActivity.vue

@@ -42,6 +42,8 @@
 import { mapState, mapGetters } from "vuex";
 import Toast from "toasters";
 
+import ws from "../../../ws";
+
 import ActivityItem from "../../../components/ui/ActivityItem.vue";
 
 export default {
@@ -75,12 +77,14 @@ export default {
 	},
 	mounted() {
 		if (this.myUserId !== this.userId) {
-			this.socket.dispatch(
-				"apis.joinRoom",
-				`profile-${this.userId}-activities`,
-				res => {
-					console.log("res of joining activities room", res);
-				}
+			ws.onConnect(() =>
+				this.socket.dispatch(
+					"apis.joinRoom",
+					`profile-${this.userId}-activities`,
+					res => {
+						console.log("res of joining activities room", res);
+					}
+				)
 			);
 		}