further code cleanup main

This commit is contained in:
Jonas Heinrich 2021-01-20 11:36:03 +01:00
parent 1b8fd50d45
commit 44e2d39252

View File

@ -59,8 +59,7 @@ import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import Navigation from './../components/Navigation' import Navigation from './../components/Navigation'
import Table from './../components/Table' import Table from './../components/Table'
import Sidebar from './../components/Sidebar' import Sidebar from './../components/Sidebar'
import { mapGetters, mapActions } from 'vuex'
import Vuex from 'vuex'
import { RadioBrowserApi } from './../services/RadioBrowserApi' import { RadioBrowserApi } from './../services/RadioBrowserApi'
const apiClient = new RadioBrowserApi() const apiClient = new RadioBrowserApi()
@ -80,11 +79,10 @@ export default {
blurHashes: require('../assets/blurHashes.json'), blurHashes: require('../assets/blurHashes.json'),
showSidebar: false, showSidebar: false,
sidebarStation: {}, sidebarStation: {},
queryParams: {},
tableData: [], tableData: [],
}), }),
computed: { computed: {
...Vuex.mapGetters([ ...mapGetters([
'favorites', 'favorites',
'recent', 'recent',
'isFavorite', 'isFavorite',
@ -97,9 +95,6 @@ export default {
} }
return this.tableData return this.tableData
}, },
player() {
return this.$store.state.player
},
emptyContentMessage() { emptyContentMessage() {
if (this.$route.name === 'FAVORITES') { if (this.$route.name === 'FAVORITES') {
return t('radio', 'No favorites yet') return t('radio', 'No favorites yet')
@ -139,6 +134,12 @@ export default {
this.scroll() this.scroll()
}, },
methods: { methods: {
...mapActions([
'addFavorite',
'removeFavorite',
'addRecent',
'playStation',
]),
onResize({ width, height }) { onResize({ width, height }) {
const contentHeight = document.getElementById('app-content-vue').scrollHeight const contentHeight = document.getElementById('app-content-vue').scrollHeight
@ -166,9 +167,9 @@ export default {
*/ */
async doFavor(station) { async doFavor(station) {
if (this.isFavorite(station)) { if (this.isFavorite(station)) {
this.$store.dispatch('removeFavorite', station) this.removeFavorite(station)
} else { } else {
this.$store.dispatch('addFavorite', station) this.addFavorite(station)
} }
}, },
@ -179,13 +180,13 @@ export default {
doPlay(station) { doPlay(station) {
/* Start streaming station */ /* Start streaming station */
this.$store.dispatch('playStation', station) this.playStation(station)
/* Count click */ /* Count click */
apiClient.countClick(station) apiClient.countClick(station)
/* Put into recent stations */ /* Put into recent stations */
this.$store.dispatch('addRecent', station) this.addRecent(station)
}, },
@ -303,6 +304,7 @@ export default {
} }
} }
}, },
toggleSidebar(station = null) { toggleSidebar(station = null) {
if (station) { if (station) {
this.showSidebar = true this.showSidebar = true
@ -311,6 +313,7 @@ export default {
this.showSidebar = false this.showSidebar = false
} }
}, },
}, },
} }
</script> </script>