[web] Lint source code

This commit is contained in:
Alain Nussbaumer 2024-03-26 15:00:17 +01:00
parent 57207c1ff4
commit 94f331cf09
13 changed files with 111 additions and 145 deletions

View File

@ -66,8 +66,8 @@ export default {
data() {
return {
url: '',
loading: false
loading: false,
url: ''
}
},
@ -75,7 +75,6 @@ export default {
show() {
if (this.show) {
this.loading = false
// We need to delay setting the focus to the input field until the field is part of the dom and visible
setTimeout(() => {
this.$refs.url_field.focus()

View File

@ -69,8 +69,8 @@ export default {
data() {
return {
url: '',
loading: false
loading: false,
url: ''
}
},

View File

@ -344,17 +344,12 @@ export default {
},
methods: {
change_volume() {
webapi.player_volume(this.player.volume)
},
change_stream_volume() {
audio.setVolume(this.stream_volume / 100)
},
toggle_mute_volume() {
this.player.volume = this.player.volume > 0 ? 0 : this.old_volume
this.change_volume()
change_volume() {
webapi.player_volume(this.player.volume)
},
closeAudio() {
audio.stop()
this.playing = false
@ -366,15 +361,12 @@ export default {
if (this.playing) {
return
}
const channel = '/stream.mp3'
this.loading = true
audio.play(channel)
audio.play('/stream.mp3')
audio.setVolume(this.stream_volume / 100)
},
setupAudio() {
const a = audio.setup()
a.addEventListener('waiting', (e) => {
this.playing = false
this.loading = true
@ -402,9 +394,13 @@ export default {
return
}
if (this.playing) {
return this.closeAudio()
this.closeAudio()
}
return this.playChannel()
this.playChannel()
},
toggle_mute_volume() {
this.player.volume = this.player.volume > 0 ? 0 : this.old_volume
this.change_volume()
}
}
}

View File

@ -17,11 +17,11 @@ export default {
},
computed: {
is_active() {
return this.$store.state.lyrics.pane
},
icon_name() {
return this.is_active ? 'script-text-play' : 'script-text-outline'
},
is_active() {
return this.$store.state.lyrics.pane
}
},

View File

@ -19,21 +19,9 @@ export default {
},
computed: {
is_playing() {
return this.$store.state.player.state === 'play'
},
is_pause_allowed() {
return (
this.$store.getters.now_playing &&
this.$store.getters.now_playing.data_kind !== 'pipe'
)
},
disabled() {
return !this.$store.state.queue || this.$store.state.queue.count <= 0
},
icon_name() {
if (!this.is_playing) {
return 'play'
@ -41,6 +29,15 @@ export default {
return 'pause'
}
return 'stop'
},
is_pause_allowed() {
return (
this.$store.getters.now_playing &&
this.$store.getters.now_playing.data_kind !== 'pipe'
)
},
is_playing() {
return this.$store.state.player.state === 'play'
}
},
@ -50,9 +47,9 @@ export default {
if (this.show_disabled_message) {
this.$store.dispatch('add_notification', {
text: this.$t('server.empty-queue'),
type: 'info',
timeout: 2000,
topic: 'connection',
timeout: 2000
type: 'info'
})
}
return

View File

@ -19,15 +19,6 @@ export default {
},
computed: {
is_repeat_all() {
return this.$store.state.player.repeat === 'all'
},
is_repeat_single() {
return this.$store.state.player.repeat === 'single'
},
is_repeat_off() {
return !this.is_repeat_all && !this.is_repeat_single
},
icon_name() {
if (this.is_repeat_all) {
return 'repeat'
@ -35,6 +26,15 @@ export default {
return 'repeat-once'
}
return 'repeat-off'
},
is_repeat_all() {
return this.$store.state.player.repeat === 'all'
},
is_repeat_off() {
return !this.is_repeat_all && !this.is_repeat_single
},
is_repeat_single() {
return this.$store.state.player.repeat === 'single'
}
},

View File

@ -19,12 +19,6 @@ export default {
},
computed: {
now_playing() {
return this.$store.getters.now_playing
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
disabled() {
return (
!this.$store.state.queue ||
@ -33,6 +27,12 @@ export default {
this.now_playing.data_kind === 'pipe'
)
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
now_playing() {
return this.$store.getters.now_playing
},
visible() {
return ['podcast', 'audiobook'].includes(this.now_playing.media_kind)
}

View File

@ -19,12 +19,6 @@ export default {
},
computed: {
now_playing() {
return this.$store.getters.now_playing
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
disabled() {
return (
!this.$store.state.queue ||
@ -33,6 +27,12 @@ export default {
this.now_playing.data_kind === 'pipe'
)
},
is_stopped() {
return this.$store.state.player.state === 'stop'
},
now_playing() {
return this.$store.getters.now_playing
},
visible() {
return ['podcast', 'audiobook'].includes(this.now_playing.media_kind)
}

View File

@ -16,21 +16,18 @@ export default {
name: 'PlayerButtonShuffle',
props: {
icon_size: {
type: Number,
default: 16
}
icon_size: { default: 16, type: Number }
},
computed: {
is_shuffle() {
return this.$store.state.player.shuffle
},
icon_name() {
if (this.is_shuffle) {
return 'shuffle'
}
return 'shuffle-disabled'
},
is_shuffle() {
return this.$store.state.player.shuffle
}
},

View File

@ -40,6 +40,20 @@ export default {
},
computed: {
info() {
if (this.is_success) {
return this.$t('setting.saved')
} else if (this.is_error) {
return this.$t('setting.not-saved')
}
return ''
},
is_error() {
return this.statusUpdate === 'error'
},
is_success() {
return this.statusUpdate === 'success'
},
option() {
const option = this.$store.getters.settings_option(
this.category_name,
@ -53,27 +67,16 @@ export default {
}
}
return option
},
info() {
if (this.is_success) {
return this.$t('setting.saved')
} else if (this.is_error) {
return this.$t('setting.not-saved')
}
return ''
},
is_success() {
return this.statusUpdate === 'success'
},
is_error() {
return this.statusUpdate === 'error'
}
},
methods: {
clear_status() {
if (this.is_error) {
this.option.value = !this.option.value
}
this.statusUpdate = ''
},
update_setting() {
this.timerId = -1
const option = {
@ -93,13 +96,6 @@ export default {
.finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
})
},
clear_status() {
if (this.is_error) {
this.option.value = !this.option.value
}
this.statusUpdate = ''
}
}
}

View File

@ -41,9 +41,9 @@ export default {
data() {
return {
statusUpdate: '',
timerDelay: 2000,
timerId: -1,
statusUpdate: ''
timerId: -1
}
},
@ -53,20 +53,6 @@ export default {
(elem) => elem.name === this.category_name
)
},
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
},
info() {
if (this.statusUpdate === 'success') {
return this.$t('setting.saved')
@ -75,17 +61,29 @@ export default {
}
return ''
},
is_error() {
return this.statusUpdate === 'error'
},
is_success() {
return this.statusUpdate === 'success'
},
is_error() {
return this.statusUpdate === 'error'
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
}
},
methods: {
clear_status() {
this.statusUpdate = ''
},
set_update_timer() {
if (this.timerId > 0) {
window.clearTimeout(this.timerId)
@ -98,16 +96,13 @@ export default {
this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
}
},
update_setting() {
this.timerId = -1
const newValue = this.$refs.setting.value
if (newValue === this.value) {
this.statusUpdate = ''
return
}
const option = {
category: this.category.name,
name: this.option_name,
@ -126,10 +121,6 @@ export default {
.finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
})
},
clear_status() {
this.statusUpdate = ''
}
}
}

View File

@ -40,9 +40,9 @@ export default {
data() {
return {
statusUpdate: '',
timerDelay: 2000,
timerId: -1,
statusUpdate: ''
timerId: -1
}
},
@ -52,20 +52,6 @@ export default {
(elem) => elem.name === this.category_name
)
},
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
},
info() {
if (this.statusUpdate === 'success') {
return this.$t('setting.saved')
@ -74,39 +60,47 @@ export default {
}
return ''
},
is_error() {
return this.statusUpdate === 'error'
},
is_success() {
return this.statusUpdate === 'success'
},
is_error() {
return this.statusUpdate === 'error'
option() {
if (!this.category) {
return {}
}
return this.category.options.find(
(elem) => elem.name === this.option_name
)
},
value() {
return this.option.value
}
},
methods: {
clear_status() {
this.statusUpdate = ''
},
set_update_timer() {
if (this.timerId > 0) {
window.clearTimeout(this.timerId)
this.timerId = -1
}
this.statusUpdate = ''
const newValue = this.$refs.setting.value
if (newValue !== this.value) {
this.timerId = window.setTimeout(this.update_setting, this.timerDelay)
}
},
update_setting() {
this.timerId = -1
const newValue = this.$refs.setting.value
if (newValue === this.value) {
this.statusUpdate = ''
return
}
const option = {
category: this.category.name,
name: this.option_name,
@ -125,10 +119,6 @@ export default {
.finally(() => {
this.timerId = window.setTimeout(this.clear_status, this.timerDelay)
})
},
clear_status() {
this.statusUpdate = ''
}
}
}

View File

@ -214,9 +214,9 @@ export default {
spotify_search(types) {
return webapi.spotify().then(({ data }) => {
this.search_param.market = data.webapi_country
const api = new SpotifyWebApi()
api.setAccessToken(data.webapi_token)
return api.search(this.query.query, types, this.search_param)
const spotifyApi = new SpotifyWebApi()
spotifyApi.setAccessToken(data.webapi_token)
return spotifyApi.search(this.query.query, types, this.search_param)
})
}
}