fix showing star on favoring station
This commit is contained in:
parent
9428cf582e
commit
3efeaa49a4
@ -11,6 +11,7 @@
|
|||||||
<Table
|
<Table
|
||||||
v-if="!pageLoading"
|
v-if="!pageLoading"
|
||||||
:station-data="tableData"
|
:station-data="tableData"
|
||||||
|
:favorites="favorites"
|
||||||
@doPlay="doPlay"
|
@doPlay="doPlay"
|
||||||
@doFavor="doFavor" />
|
@doFavor="doFavor" />
|
||||||
<EmptyContent
|
<EmptyContent
|
||||||
@ -97,8 +98,12 @@ export default {
|
|||||||
*/
|
*/
|
||||||
async doFavor(station) {
|
async doFavor(station) {
|
||||||
try {
|
try {
|
||||||
await axios.post(generateUrl('/apps/radio/api/favorites'), station)
|
await axios
|
||||||
} catch (e) {
|
.post(generateUrl('/apps/radio/api/favorites'), station)
|
||||||
|
.then(response => {
|
||||||
|
this.favorites.push(station.stationuuid)
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
showError(t('radio', 'Could not favor station'))
|
showError(t('radio', 'Could not favor station'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -211,9 +216,14 @@ export default {
|
|||||||
this.$store.dispatch('getVolumeState')
|
this.$store.dispatch('getVolumeState')
|
||||||
},
|
},
|
||||||
async loadFavorites() {
|
async loadFavorites() {
|
||||||
|
const vm = this
|
||||||
await axios.get(generateUrl('/apps/radio/api/favorites'))
|
await axios.get(generateUrl('/apps/radio/api/favorites'))
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
this.favorites = response.data
|
const favorites = []
|
||||||
|
for (let i = 0, len = response.data.length; i < len; i++) {
|
||||||
|
favorites.push(response.data[i].stationuuid)
|
||||||
|
}
|
||||||
|
vm.favorites = favorites
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
height="32"
|
height="32"
|
||||||
:hash="station.blurHash"
|
:hash="station.blurHash"
|
||||||
:src="station.favicon" />
|
:src="station.favicon" />
|
||||||
<span :class="{ 'icon-starred': stationsFavored.includes(idx) }" />
|
<span :class="{ 'icon-starred': favorites.includes(station.stationuuid) }" />
|
||||||
</td>
|
</td>
|
||||||
<td class="nameColumn" @click="doPlay(idx, station)">
|
<td class="nameColumn" @click="doPlay(idx, station)">
|
||||||
<span class="innernametext">
|
<span class="innernametext">
|
||||||
@ -54,6 +54,10 @@ export default {
|
|||||||
ActionButton,
|
ActionButton,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
favorites: {
|
||||||
|
type: Array,
|
||||||
|
default() { return [] },
|
||||||
|
},
|
||||||
stationData: {
|
stationData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default() { return [] },
|
default() { return [] },
|
||||||
@ -61,7 +65,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
activeItem: null,
|
activeItem: null,
|
||||||
stationsFavored: [1, 2, 3, 4],
|
|
||||||
}),
|
}),
|
||||||
methods: {
|
methods: {
|
||||||
doPlay(idx, station) {
|
doPlay(idx, station) {
|
||||||
|
Loading…
Reference in New Issue
Block a user