|
@@ -23,7 +23,7 @@
|
|
</a>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<router-link
|
|
<router-link
|
|
- v-for="(station, index) in filteredStations()"
|
|
|
|
|
|
+ v-for="(station, index) in filteredStations"
|
|
:key="index"
|
|
:key="index"
|
|
:to="{
|
|
:to="{
|
|
name: 'station',
|
|
name: 'station',
|
|
@@ -194,7 +194,27 @@ export default {
|
|
loggedIn: state => state.user.auth.loggedIn,
|
|
loggedIn: state => state.user.auth.loggedIn,
|
|
userId: state => state.user.auth.userId,
|
|
userId: state => state.user.auth.userId,
|
|
modals: state => state.modals.modals.home
|
|
modals: state => state.modals.modals.home
|
|
- })
|
|
|
|
|
|
+ }),
|
|
|
|
+ filteredStations() {
|
|
|
|
+ const privacyOrder = ["public", "unlisted", "private"];
|
|
|
|
+ return this.stations
|
|
|
|
+ .filter(
|
|
|
|
+ station =>
|
|
|
|
+ JSON.stringify(Object.values(station)).indexOf(
|
|
|
|
+ this.searchQuery
|
|
|
|
+ ) !== -1
|
|
|
|
+ )
|
|
|
|
+ .sort(
|
|
|
|
+ (a, b) =>
|
|
|
|
+ this.isFavorite(b) - this.isFavorite(a) ||
|
|
|
|
+ this.isOwner(b) - this.isOwner(a) ||
|
|
|
|
+ this.isPlaying(b) - this.isPlaying(a) ||
|
|
|
|
+ a.paused - b.paused ||
|
|
|
|
+ privacyOrder.indexOf(a.privacy) -
|
|
|
|
+ privacyOrder.indexOf(b.privacy) ||
|
|
|
|
+ b.userCount - a.userCount
|
|
|
|
+ );
|
|
|
|
+ }
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
io.getSocket(socket => {
|
|
io.getSocket(socket => {
|
|
@@ -278,26 +298,6 @@ export default {
|
|
});
|
|
});
|
|
this.socket.emit("apis.joinRoom", "home", () => {});
|
|
this.socket.emit("apis.joinRoom", "home", () => {});
|
|
},
|
|
},
|
|
- filteredStations() {
|
|
|
|
- const privacyOrder = ["public", "unlisted", "private"];
|
|
|
|
- return this.stations
|
|
|
|
- .filter(
|
|
|
|
- station =>
|
|
|
|
- JSON.stringify(Object.values(station)).indexOf(
|
|
|
|
- this.searchQuery
|
|
|
|
- ) !== -1
|
|
|
|
- )
|
|
|
|
- .sort(
|
|
|
|
- (a, b) =>
|
|
|
|
- this.isFavorite(b) - this.isFavorite(a) ||
|
|
|
|
- this.isOwner(b) - this.isOwner(a) ||
|
|
|
|
- this.isPlaying(b) - this.isPlaying(a) ||
|
|
|
|
- a.paused - b.paused ||
|
|
|
|
- privacyOrder.indexOf(a.privacy) -
|
|
|
|
- privacyOrder.indexOf(b.privacy) ||
|
|
|
|
- b.userCount - a.userCount
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
isOwner(station) {
|
|
isOwner(station) {
|
|
return station.owner === this.userId;
|
|
return station.owner === this.userId;
|
|
},
|
|
},
|