From f3a65ae93a1a91ab7ba47f0035be37cb6af7e618 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Sun, 8 Nov 2020 10:18:08 +0100 Subject: [PATCH] starting to implement remove station from favorites --- src/components/Main.vue | 12 +++++++++--- src/components/Table.vue | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/Main.vue b/src/components/Main.vue index 3000fa7..ed82ffc 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -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 }) diff --git a/src/components/Table.vue b/src/components/Table.vue index 95c6da0..59a3738 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -21,7 +21,7 @@ height="32" :hash="station.blurHash" :src="station.favicon" /> - + @@ -31,14 +31,14 @@ {{ t('radio', 'Add to favorites') }}