starting to implement remove station from favorites
This commit is contained in:
parent
c4d6045194
commit
f3a65ae93a
@ -97,10 +97,16 @@ export default {
|
||||
* @param {Object} station Station object
|
||||
*/
|
||||
async doFavor(station) {
|
||||
if (this.favorites.includes(station.stationuuid)) {
|
||||
if (this.favorites.flat().includes(station.stationuuid)) {
|
||||
let stationid = null
|
||||
try {
|
||||
for (let i = 0, len = this.favorites.length; i < len; i++) {
|
||||
if (station.stationuuid === this.favorites[i][1]) {
|
||||
stationid = this.favorites[i][0]
|
||||
}
|
||||
}
|
||||
await axios
|
||||
.delete(generateUrl(`/apps/radio/api/favorites/${station.id}`))
|
||||
.delete(generateUrl(`/apps/radio/api/favorites/${stationid}`))
|
||||
.then(response => {
|
||||
this.favorites = this.favorites.filter(item => item !== station.stationuuid)
|
||||
})
|
||||
@ -233,7 +239,7 @@ export default {
|
||||
.then(function(response) {
|
||||
const favorites = []
|
||||
for (let i = 0, len = response.data.length; i < len; i++) {
|
||||
favorites.push(response.data[i].stationuuid)
|
||||
favorites.push([response.data[i].id, response.data[i].stationuuid])
|
||||
}
|
||||
vm.favorites = favorites
|
||||
})
|
||||
|
@ -21,7 +21,7 @@
|
||||
height="32"
|
||||
:hash="station.blurHash"
|
||||
:src="station.favicon" />
|
||||
<span :class="{ 'icon-starred': favorites.includes(station.stationuuid) }" />
|
||||
<span :class="{ 'icon-starred': favorites.flat().includes(station.stationuuid) }" />
|
||||
</td>
|
||||
<td class="nameColumn" @click="doPlay(idx, station)">
|
||||
<span class="innernametext">
|
||||
@ -31,14 +31,14 @@
|
||||
<td class="actionColumn">
|
||||
<Actions>
|
||||
<ActionButton
|
||||
v-if="!favorites.includes(station.stationuuid)"
|
||||
v-if="!favorites.flat().includes(station.stationuuid)"
|
||||
icon="icon-star"
|
||||
:close-after-click="true"
|
||||
@click="doFavor(idx, station)">
|
||||
{{ t('radio', 'Add to favorites') }}
|
||||
</ActionButton>
|
||||
<ActionButton
|
||||
v-if="favorites.includes(station.stationuuid)"
|
||||
v-if="favorites.flat().includes(station.stationuuid)"
|
||||
icon="icon-star"
|
||||
:close-after-click="true"
|
||||
@click="doFavor(idx, station)">
|
||||
|
Loading…
Reference in New Issue
Block a user