diff --git a/appinfo/routes.php b/appinfo/routes.php index dcb9be0..ee82c4e 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -24,9 +24,7 @@ return [ 'resources' => [ 'favorite' => ['url' => '/api/favorites'], - 'favorite_api' => ['url' => '/api/0.1/favorites'], 'recent' => ['url' => '/api/recents'], - 'recent_api' => ['url' => '/api/0.1/recents'] ], 'routes' => [ diff --git a/lib/Controller/FavoriteApiController.php b/lib/Controller/FavoriteApiController.php deleted file mode 100644 index cd9062b..0000000 --- a/lib/Controller/FavoriteApiController.php +++ /dev/null @@ -1,80 +0,0 @@ -service = $service; - $this->userId = $userId; - } - - /** - * @CORS - * @NoCSRFRequired - * @NoAdminRequired - */ - public function index(): DataResponse { - return new DataResponse($this->service->findAll($this->userId)); - } - - /** - * @CORS - * @NoCSRFRequired - * @NoAdminRequired - */ - public function show(int $id): DataResponse { - return $this->handleNotFound(function () use ($id) { - return $this->service->find($id, $this->userId); - }); - } - - /** - * @CORS - * @NoCSRFRequired - * @NoAdminRequired - */ - public function create(string $stationuuid, string $name, string $favicon, string $urlresolved): DataResponse { - return new DataResponse($this->service->create($stationuuid, $name, - $favicon, $urlresolved, $this->userId)); - } - - /** - * @CORS - * @NoCSRFRequired - * @NoAdminRequired - */ - public function update(int $id, string $title, - string $content): DataResponse { - return $this->handleNotFound(function () use ($id, $stationuuid, $name, $favicon, $urlresolved) { - return $this->service->update($id, $stationuuid, $name, $favicon, $urlresolved, $this->userId); - }); - } - - /** - * @CORS - * @NoCSRFRequired - * @NoAdminRequired - */ - public function destroy(int $id): DataResponse { - return $this->handleNotFound(function () use ($id) { - return $this->service->delete($id, $this->userId); - }); - } -} diff --git a/lib/Controller/FavoriteController.php b/lib/Controller/FavoriteController.php index b0029f8..c6221de 100644 --- a/lib/Controller/FavoriteController.php +++ b/lib/Controller/FavoriteController.php @@ -44,7 +44,7 @@ class FavoriteController extends Controller { /** * @NoAdminRequired */ - public function create(string $stationuuid, string $name, string $favicon, string $urlresolved = "lol"): DataResponse { + public function create(string $stationuuid, string $name, string $favicon, string $urlresolved): DataResponse { return new DataResponse($this->service->create($stationuuid, $name, $favicon, $urlresolved, $this->userId)); } diff --git a/lib/Db/Station.php b/lib/Db/Station.php index 506dfd0..8780fa1 100644 --- a/lib/Db/Station.php +++ b/lib/Db/Station.php @@ -19,7 +19,7 @@ class Station extends Entity implements JsonSerializable { 'stationuuid' => $this->stationuuid, 'name' => $this->name, 'favicon' => $this->favicon, - 'url_resolved' => $this->urlresolved + 'urlresolved' => $this->urlresolved ]; } } diff --git a/src/components/Main.vue b/src/components/Main.vue index 242cce0..6fd8d7e 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -71,7 +71,6 @@ export default { }, data: () => ({ tableData: [], - offset: 0, pageLoading: false, blurHashes: require('../assets/blurHashes.json'), favorites: null, @@ -107,8 +106,8 @@ export default { methods: { async onRoute() { - this.offset = 0 this.tableData = [] + this.pageLoading = true const route = this.$route this.loadStations(route.name) }, @@ -136,8 +135,15 @@ export default { } } else { try { + const stationMap = { + id: -1, + name: station.name, + urlresolved: station.url_resolved, + favicon: station.favicon, + stationuuid: station.stationuuid, + } await axios - .post(generateUrl('/apps/radio/api/favorites'), station) + .post(generateUrl('/apps/radio/api/favorites'), stationMap) .then(response => { this.favorites.push([response.data.id, station.stationuuid]) }) @@ -159,8 +165,14 @@ export default { } vm.$store.dispatch('setTitle', station.name) + let stationSrc = '' + if (!station.url_resolved) { + stationSrc = station.urlresolved + } else { + stationSrc = station.url_resolved + } audioPlayer = new Howl({ - src: [station.url_resolved], + src: stationSrc, volume: vm.player.volume, /* onfade() { // FIXME if (this.volume() === 0) { @@ -202,11 +214,6 @@ export default { let queryURI = queryBase let sortBy = 'clickcount' - // Inital page loading - if (vm.offset === 0) { - vm.pageLoading = true - } - if (vm.$route.name === 'CATEGORIES') { vm.tableData = [ { @@ -234,8 +241,8 @@ export default { return true } - // Skip loading more stations on certain sites - if (vm.offset > 0 + // FIXME: Skip loading more stations on certain sites + if (vm.tableData.length > 0 && (vm.$route.name === 'FAVORITES' || vm.$route.name === 'RECENT')) { return true @@ -246,9 +253,7 @@ export default { } else if (menuState === 'NEW') { sortBy = 'lastchangetime' } else if (menuState === 'SEARCH') { - // const searchQuery = vm.$route.hash.substr(1) const searchQuery = vm.$route.params.query - console.log(searchQuery) queryURI = queryBase + '/byname/' + searchQuery } else if (menuState === 'FAVORITES') { queryURI = generateUrl('/apps/radio/api/favorites') @@ -259,7 +264,7 @@ export default { limit: 20, order: sortBy, reverse: true, - offset: vm.offset, + offset: vm.tableData.length, }, }) .then(function(response) { @@ -272,7 +277,6 @@ export default { response.data[i].blurHash = blurHash } vm.tableData = vm.tableData.concat(response.data) - vm.offset += 20 vm.pageLoading = false }) }, diff --git a/src/components/Player.vue b/src/components/Player.vue index 6c27f4b..8f1e528 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -54,10 +54,6 @@ export default {