|
@@ -108,15 +108,27 @@
|
|
title="This is your station."
|
|
title="This is your station."
|
|
>home</i
|
|
>home</i
|
|
>
|
|
>
|
|
|
|
+ <button
|
|
|
|
+ v-if="!isFavorite(station)"
|
|
|
|
+ @click="favoriteStation($event, station)"
|
|
|
|
+ >
|
|
|
|
+ Favorite
|
|
|
|
+ </button>
|
|
|
|
+ <button
|
|
|
|
+ v-if="isFavorite(station)"
|
|
|
|
+ @click="unfavoriteStation($event, station)"
|
|
|
|
+ >
|
|
|
|
+ Unfavorite
|
|
|
|
+ </button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <router-link
|
|
|
|
|
|
+ <!--router-link
|
|
class="absolute-a"
|
|
class="absolute-a"
|
|
:to="{
|
|
:to="{
|
|
name: 'station',
|
|
name: 'station',
|
|
params: { id: station.name }
|
|
params: { id: station.name }
|
|
}"
|
|
}"
|
|
- />
|
|
|
|
|
|
+ /-->
|
|
</router-link>
|
|
</router-link>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -128,6 +140,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { mapState, mapActions } from "vuex";
|
|
import { mapState, mapActions } from "vuex";
|
|
|
|
+import { Toast } from "vue-roaster";
|
|
|
|
|
|
import MainHeader from "../MainHeader.vue";
|
|
import MainHeader from "../MainHeader.vue";
|
|
import MainFooter from "../MainFooter.vue";
|
|
import MainFooter from "../MainFooter.vue";
|
|
@@ -143,6 +156,7 @@ export default {
|
|
key: ""
|
|
key: ""
|
|
},
|
|
},
|
|
stations: [],
|
|
stations: [],
|
|
|
|
+ favoriteStations: [],
|
|
searchQuery: ""
|
|
searchQuery: ""
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -205,6 +219,12 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ this.socket.on("event:user.favoritedStation", stationId => {
|
|
|
|
+ this.favoriteStations.push(stationId);
|
|
|
|
+ });
|
|
|
|
+ this.socket.on("event:user.unfavoritedStation", stationId => {
|
|
|
|
+ this.favoriteStations.$remove(stationId);
|
|
|
|
+ });
|
|
});
|
|
});
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -226,6 +246,10 @@ export default {
|
|
this.stations.push(station);
|
|
this.stations.push(station);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ this.socket.emit("users.getFavoriteStations", data => {
|
|
|
|
+ if (data.status === "success")
|
|
|
|
+ this.favoriteStations = data.favoriteStations;
|
|
|
|
+ });
|
|
this.socket.emit("apis.joinRoom", "home", () => {});
|
|
this.socket.emit("apis.joinRoom", "home", () => {});
|
|
},
|
|
},
|
|
isOwner(station) {
|
|
isOwner(station) {
|
|
@@ -233,6 +257,31 @@ export default {
|
|
station.owner === this.userId && station.privacy === "public"
|
|
station.owner === this.userId && station.privacy === "public"
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
+ isFavorite(station) {
|
|
|
|
+ return this.favoriteStations.indexOf(station._id) !== -1;
|
|
|
|
+ },
|
|
|
|
+ favoriteStation(event, station) {
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ this.socket.emit("stations.favoriteStation", station._id, res => {
|
|
|
|
+ if (res.status === "success") {
|
|
|
|
+ Toast.methods.addToast(
|
|
|
|
+ "Successfully favorited station.",
|
|
|
|
+ 4000
|
|
|
|
+ );
|
|
|
|
+ } else Toast.methods.addToast(res.message, 8000);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ unfavoriteStation(event, station) {
|
|
|
|
+ event.preventDefault();
|
|
|
|
+ this.socket.emit("stations.unfavoriteStation", station._id, res => {
|
|
|
|
+ if (res.status === "success") {
|
|
|
|
+ Toast.methods.addToast(
|
|
|
|
+ "Successfully unfavorited station.",
|
|
|
|
+ 4000
|
|
|
|
+ );
|
|
|
|
+ } else Toast.methods.addToast(res.message, 8000);
|
|
|
|
+ });
|
|
|
|
+ },
|
|
...mapActions("modals", ["openModal"])
|
|
...mapActions("modals", ["openModal"])
|
|
},
|
|
},
|
|
components: {
|
|
components: {
|