fix playing favorite stations
This commit is contained in:
parent
f3c64ac7b1
commit
67f4bebefc
@ -24,9 +24,7 @@
|
|||||||
return [
|
return [
|
||||||
'resources' => [
|
'resources' => [
|
||||||
'favorite' => ['url' => '/api/favorites'],
|
'favorite' => ['url' => '/api/favorites'],
|
||||||
'favorite_api' => ['url' => '/api/0.1/favorites'],
|
|
||||||
'recent' => ['url' => '/api/recents'],
|
'recent' => ['url' => '/api/recents'],
|
||||||
'recent_api' => ['url' => '/api/0.1/recents']
|
|
||||||
],
|
],
|
||||||
'routes' => [
|
'routes' => [
|
||||||
|
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace OCA\Radio\Controller;
|
|
||||||
|
|
||||||
use OCA\Radio\AppInfo\Application;
|
|
||||||
use OCA\Radio\Service\StationService;
|
|
||||||
use OCP\AppFramework\ApiController;
|
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
|
||||||
use OCP\IRequest;
|
|
||||||
|
|
||||||
class FavoriteApiController extends ApiController {
|
|
||||||
/** @var StationService */
|
|
||||||
private $service;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $userId;
|
|
||||||
|
|
||||||
use Errors;
|
|
||||||
|
|
||||||
public function __construct(IRequest $request,
|
|
||||||
StationService $service,
|
|
||||||
$userId) {
|
|
||||||
parent::__construct(Application::APP_ID, $request);
|
|
||||||
$this->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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -44,7 +44,7 @@ class FavoriteController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @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,
|
return new DataResponse($this->service->create($stationuuid, $name,
|
||||||
$favicon, $urlresolved, $this->userId));
|
$favicon, $urlresolved, $this->userId));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ class Station extends Entity implements JsonSerializable {
|
|||||||
'stationuuid' => $this->stationuuid,
|
'stationuuid' => $this->stationuuid,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'favicon' => $this->favicon,
|
'favicon' => $this->favicon,
|
||||||
'url_resolved' => $this->urlresolved
|
'urlresolved' => $this->urlresolved
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,6 @@ export default {
|
|||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
tableData: [],
|
tableData: [],
|
||||||
offset: 0,
|
|
||||||
pageLoading: false,
|
pageLoading: false,
|
||||||
blurHashes: require('../assets/blurHashes.json'),
|
blurHashes: require('../assets/blurHashes.json'),
|
||||||
favorites: null,
|
favorites: null,
|
||||||
@ -107,8 +106,8 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
async onRoute() {
|
async onRoute() {
|
||||||
this.offset = 0
|
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
|
this.pageLoading = true
|
||||||
const route = this.$route
|
const route = this.$route
|
||||||
this.loadStations(route.name)
|
this.loadStations(route.name)
|
||||||
},
|
},
|
||||||
@ -136,8 +135,15 @@ export default {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
const stationMap = {
|
||||||
|
id: -1,
|
||||||
|
name: station.name,
|
||||||
|
urlresolved: station.url_resolved,
|
||||||
|
favicon: station.favicon,
|
||||||
|
stationuuid: station.stationuuid,
|
||||||
|
}
|
||||||
await axios
|
await axios
|
||||||
.post(generateUrl('/apps/radio/api/favorites'), station)
|
.post(generateUrl('/apps/radio/api/favorites'), stationMap)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.favorites.push([response.data.id, station.stationuuid])
|
this.favorites.push([response.data.id, station.stationuuid])
|
||||||
})
|
})
|
||||||
@ -159,8 +165,14 @@ export default {
|
|||||||
}
|
}
|
||||||
vm.$store.dispatch('setTitle', station.name)
|
vm.$store.dispatch('setTitle', station.name)
|
||||||
|
|
||||||
|
let stationSrc = ''
|
||||||
|
if (!station.url_resolved) {
|
||||||
|
stationSrc = station.urlresolved
|
||||||
|
} else {
|
||||||
|
stationSrc = station.url_resolved
|
||||||
|
}
|
||||||
audioPlayer = new Howl({
|
audioPlayer = new Howl({
|
||||||
src: [station.url_resolved],
|
src: stationSrc,
|
||||||
volume: vm.player.volume,
|
volume: vm.player.volume,
|
||||||
/* onfade() { // FIXME
|
/* onfade() { // FIXME
|
||||||
if (this.volume() === 0) {
|
if (this.volume() === 0) {
|
||||||
@ -202,11 +214,6 @@ export default {
|
|||||||
let queryURI = queryBase
|
let queryURI = queryBase
|
||||||
let sortBy = 'clickcount'
|
let sortBy = 'clickcount'
|
||||||
|
|
||||||
// Inital page loading
|
|
||||||
if (vm.offset === 0) {
|
|
||||||
vm.pageLoading = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.$route.name === 'CATEGORIES') {
|
if (vm.$route.name === 'CATEGORIES') {
|
||||||
vm.tableData = [
|
vm.tableData = [
|
||||||
{
|
{
|
||||||
@ -234,8 +241,8 @@ export default {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip loading more stations on certain sites
|
// FIXME: Skip loading more stations on certain sites
|
||||||
if (vm.offset > 0
|
if (vm.tableData.length > 0
|
||||||
&& (vm.$route.name === 'FAVORITES'
|
&& (vm.$route.name === 'FAVORITES'
|
||||||
|| vm.$route.name === 'RECENT')) {
|
|| vm.$route.name === 'RECENT')) {
|
||||||
return true
|
return true
|
||||||
@ -246,9 +253,7 @@ export default {
|
|||||||
} else if (menuState === 'NEW') {
|
} else if (menuState === 'NEW') {
|
||||||
sortBy = 'lastchangetime'
|
sortBy = 'lastchangetime'
|
||||||
} else if (menuState === 'SEARCH') {
|
} else if (menuState === 'SEARCH') {
|
||||||
// const searchQuery = vm.$route.hash.substr(1)
|
|
||||||
const searchQuery = vm.$route.params.query
|
const searchQuery = vm.$route.params.query
|
||||||
console.log(searchQuery)
|
|
||||||
queryURI = queryBase + '/byname/' + searchQuery
|
queryURI = queryBase + '/byname/' + searchQuery
|
||||||
} else if (menuState === 'FAVORITES') {
|
} else if (menuState === 'FAVORITES') {
|
||||||
queryURI = generateUrl('/apps/radio/api/favorites')
|
queryURI = generateUrl('/apps/radio/api/favorites')
|
||||||
@ -259,7 +264,7 @@ export default {
|
|||||||
limit: 20,
|
limit: 20,
|
||||||
order: sortBy,
|
order: sortBy,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
offset: vm.offset,
|
offset: vm.tableData.length,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
@ -272,7 +277,6 @@ export default {
|
|||||||
response.data[i].blurHash = blurHash
|
response.data[i].blurHash = blurHash
|
||||||
}
|
}
|
||||||
vm.tableData = vm.tableData.concat(response.data)
|
vm.tableData = vm.tableData.concat(response.data)
|
||||||
vm.offset += 20
|
|
||||||
vm.pageLoading = false
|
vm.pageLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -54,10 +54,6 @@ export default {
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
#app-settings {
|
|
||||||
margin-bottom: -5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
background: var(--color-main-background);
|
background: var(--color-main-background);
|
||||||
border: 3px solid #0082c9;
|
border: 3px solid #0082c9;
|
||||||
|
Loading…
Reference in New Issue
Block a user