Browse Source

Fixed some issues with stations.

KrisVos130 8 years ago
parent
commit
d61fe72981
4 changed files with 17 additions and 8 deletions
  1. 8 3
      backend/logic/actions/stations.js
  2. 5 1
      frontend/App.vue
  3. 1 1
      frontend/components/pages/Home.vue
  4. 3 3
      frontend/main.js

+ 8 - 3
backend/logic/actions/stations.js

@@ -89,8 +89,13 @@ module.exports = {
 					message: 'An error occurred while obtaining the stations'
 				});
 			}
+			let arr = [];
+			for (var prop in stations) {
+				console.log(prop);
+				arr.push(stations[prop]);
+			}
 
-			cb({ status: 'success', stations });
+			cb({ status: 'success', stations: arr });
 		});
 	},
 
@@ -164,11 +169,11 @@ module.exports = {
 	 * Leaves the users current station
 	 *
 	 * @param session
-	 * @param stationId - the station id
 	 * @param cb
 	 * @return {{ status: String, userCount: Integer }}
 	 */
-	leave: (session, stationId, cb) => {
+	leave: (session, cb) => {
+		let stationId = "edm";
 		initializeAndReturnStation(stationId, (err, station) => {
 
 			if (err && err !== true) {

+ 5 - 1
frontend/App.vue

@@ -36,7 +36,11 @@
 			lofig.get('socket.url', res => {
 				let socket = this.socket = io(window.location.protocol + '//' + res);
 				socket.on("ready", status => this.loggedIn = status);
-				socket.emit("stations.index", data => this.stations = data);
+				socket.emit("stations.index", data => {
+					if (data.status === "success") {
+						this.stations = data.stations;
+					}
+				});
 			});
 		},
 		events: {

+ 1 - 1
frontend/components/pages/Home.vue

@@ -55,7 +55,7 @@
 		<div class="group">
 			<!--<div class="group-title">{{group.name}}</div>-->
 			<div class="group-stations">
-				<div class="stations-station" v-for="station in $parent.stations" v-link="{ path: '/station/' + station.name }" @click="this.$dispatch('joinStation', station.id)">
+				<div class="stations-station" v-for="station in $parent.stations" v-link="{ path: '/' + station.name }" @click="this.$dispatch('joinStation', station.id)">
 					<img class="station-image" :src="station.playlist[station.currentSongIndex].thumbnail" />
 					<div class="station-info">
 						<div class="station-grid-left">

+ 3 - 3
frontend/main.js

@@ -23,11 +23,11 @@ router.map({
 	'/u/:username/settings': {
 		component: Settings
 	},
-	'/station/:name': {
-		component: Station
-	},
 	'/admin': {
 		component: Admin
+	},
+	'/:name': {
+		component: Station
 	}
 });