diff --git a/appinfo/routes.php b/appinfo/routes.php index e374330..79bc45b 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -98,7 +98,7 @@ return [ // Api [ - 'name' => 'station_api#preflighted_cors', + 'name' => 'favorite_api#preflighted_cors', 'url' => '/api/0.1/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+'] diff --git a/lib/Controller/FavoriteController.php b/lib/Controller/FavoriteController.php index f3940af..b0029f8 100644 --- a/lib/Controller/FavoriteController.php +++ b/lib/Controller/FavoriteController.php @@ -15,6 +15,8 @@ class FavoriteController extends Controller { /** @var string */ private $userId; + use Errors; + public function __construct(IRequest $request, StationService $service, $userId) { diff --git a/src/components/Main.vue b/src/components/Main.vue index ed82ffc..aaf180d 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -108,7 +108,7 @@ export default { await axios .delete(generateUrl(`/apps/radio/api/favorites/${stationid}`)) .then(response => { - this.favorites = this.favorites.filter(item => item !== station.stationuuid) + this.favorites = this.favorites.filter(item => item[1] !== station.stationuuid) }) } catch (error) { showError(t('radio', 'Could not remove station from favorites')) @@ -118,7 +118,7 @@ export default { await axios .post(generateUrl('/apps/radio/api/favorites'), station) .then(response => { - this.favorites.push(station.stationuuid) + this.favorites.push([response.data.id, station.stationuuid]) }) } catch (error) { showError(t('radio', 'Could not favor station')) @@ -230,9 +230,16 @@ export default { } } }, + loadSettings() { + + axios.defaults.headers.common = { + 'User-Agent': 'Nextcloud Radio App/1.0', // FIXME: Reference global version number + } this.$store.dispatch('getVolumeState') + }, + async loadFavorites() { const vm = this await axios.get(generateUrl('/apps/radio/api/favorites'))