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
|
* @param {Object} station Station object
|
||||||
*/
|
*/
|
||||||
async doFavor(station) {
|
async doFavor(station) {
|
||||||
if (this.favorites.includes(station.stationuuid)) {
|
if (this.favorites.flat().includes(station.stationuuid)) {
|
||||||
|
let stationid = null
|
||||||
try {
|
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
|
await axios
|
||||||
.delete(generateUrl(`/apps/radio/api/favorites/${station.id}`))
|
.delete(generateUrl(`/apps/radio/api/favorites/${stationid}`))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.favorites = this.favorites.filter(item => item !== station.stationuuid)
|
this.favorites = this.favorites.filter(item => item !== station.stationuuid)
|
||||||
})
|
})
|
||||||
@ -233,7 +239,7 @@ export default {
|
|||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
const favorites = []
|
const favorites = []
|
||||||
for (let i = 0, len = response.data.length; i < len; i++) {
|
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
|
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': favorites.includes(station.stationuuid) }" />
|
<span :class="{ 'icon-starred': favorites.flat().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">
|
||||||
@ -31,14 +31,14 @@
|
|||||||
<td class="actionColumn">
|
<td class="actionColumn">
|
||||||
<Actions>
|
<Actions>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
v-if="!favorites.includes(station.stationuuid)"
|
v-if="!favorites.flat().includes(station.stationuuid)"
|
||||||
icon="icon-star"
|
icon="icon-star"
|
||||||
:close-after-click="true"
|
:close-after-click="true"
|
||||||
@click="doFavor(idx, station)">
|
@click="doFavor(idx, station)">
|
||||||
{{ t('radio', 'Add to favorites') }}
|
{{ t('radio', 'Add to favorites') }}
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
v-if="favorites.includes(station.stationuuid)"
|
v-if="favorites.flat().includes(station.stationuuid)"
|
||||||
icon="icon-star"
|
icon="icon-star"
|
||||||
:close-after-click="true"
|
:close-after-click="true"
|
||||||
@click="doFavor(idx, station)">
|
@click="doFavor(idx, station)">
|
||||||
|
Loading…
Reference in New Issue
Block a user