diff --git a/web-src/eslint.config.js b/web-src/eslint.config.js index e25aed9f..c7235398 100644 --- a/web-src/eslint.config.js +++ b/web-src/eslint.config.js @@ -25,21 +25,16 @@ export default [ 'max-statements': 'off', 'no-bitwise': 'off', 'no-magic-numbers': 'off', - 'no-negated-condition': 'off', 'no-nested-ternary': 'off', 'no-plusplus': 'off', - 'no-shadow': 'off', 'no-ternary': 'off', 'no-undef': 'off', 'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }], - 'no-useless-assignment': 'off', 'one-var': 'off', - 'prefer-named-capture-group': 'off', 'sort-keys': 'off', 'vue/html-self-closing': 'off', 'vue/max-attributes-per-line': 'off', - 'vue/prop-name-casing': 'off', - 'vue/singleline-html-element-content-newline': 'off' + 'vue/prop-name-casing': 'off' } } ] diff --git a/web-src/src/App.vue b/web-src/src/App.vue index 5fd2c825..25d2ea03 100644 --- a/web-src/src/App.vue +++ b/web-src/src/App.vue @@ -265,17 +265,6 @@ export default { document.querySelector('html').classList.remove('is-clipped') } }, - update_outputs() { - webapi.outputs().then(({ data }) => { - this.$store.commit(types.UPDATE_OUTPUTS, data.outputs) - }) - }, - update_player_status() { - webapi.player_status().then(({ data }) => { - this.$store.commit(types.UPDATE_PLAYER_STATUS, data) - this.update_lyrics() - }) - }, update_lastfm() { webapi.lastfm().then(({ data }) => { this.$store.commit(types.UPDATE_LASTFM, data) @@ -299,12 +288,23 @@ export default { this.$store.commit(types.UPDATE_LYRICS) } }, + update_outputs() { + webapi.outputs().then(({ data }) => { + this.$store.commit(types.UPDATE_OUTPUTS, data.outputs) + }) + }, update_pairing() { webapi.pairing().then(({ data }) => { this.$store.commit(types.UPDATE_PAIRING, data) this.pairing_active = data.active }) }, + update_player_status() { + webapi.player_status().then(({ data }) => { + this.$store.commit(types.UPDATE_PLAYER_STATUS, data) + this.update_lyrics() + }) + }, update_queue() { webapi.queue().then(({ data }) => { this.$store.commit(types.UPDATE_QUEUE, data) diff --git a/web-src/src/components/ListAlbums.vue b/web-src/src/components/ListAlbums.vue index c674b52c..2333bfa7 100644 --- a/web-src/src/components/ListAlbums.vue +++ b/web-src/src/components/ListAlbums.vue @@ -94,7 +94,7 @@ export default { return this.media_kind || this.selected_item.media_kind }, show_artwork() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_cover_artwork_in_album_lists' ).value @@ -122,10 +122,10 @@ export default { open_remove_podcast_dialog() { webapi .library_album_tracks(this.selected_item.id, { limit: 1 }) - .then(({ data }) => { - webapi.library_track_playlists(data.items[0].id).then(({ data }) => { + .then(({ data: album }) => { + webapi.library_track_playlists(album.items[0].id).then(({ data }) => { ;[this.rss_playlist_to_remove] = data.items.filter( - (pl) => pl.type === 'rss' + (playlist) => playlist.type === 'rss' ) this.show_remove_podcast_modal = true this.show_details_modal = false diff --git a/web-src/src/components/ListAlbumsSpotify.vue b/web-src/src/components/ListAlbumsSpotify.vue index 1684f4d7..08c22044 100644 --- a/web-src/src/components/ListAlbumsSpotify.vue +++ b/web-src/src/components/ListAlbumsSpotify.vue @@ -53,7 +53,7 @@ export default { computed: { show_artwork() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_cover_artwork_in_album_lists' ).value diff --git a/web-src/src/components/LyricsPane.vue b/web-src/src/components/LyricsPane.vue index 2b555cad..72cb50f6 100644 --- a/web-src/src/components/LyricsPane.vue +++ b/web-src/src/components/LyricsPane.vue @@ -55,31 +55,28 @@ export default { const parsed = [] if (raw) { // Parse the lyrics - const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/u - raw.split('\n').forEach((item, index) => { - const matches = regex.exec(item) - if (matches && matches[4]) { + const regex = + /\[(?\d+):(?\d+)(?:\.(?\d+))?\] ?(?.*)/u + raw.split('\n').forEach((line) => { + const { text, minutes, seconds, hundredths } = regex.exec(line).groups + if (text) { const verse = { - text: matches[4], - time: matches[2] * 60 + Number(matches[3]) + text, + time: + minutes * 60 + Number(seconds) + Number(`.${hundredths || 0}`) } parsed.push(verse) } }) // Split the verses into words parsed.forEach((verse, index, lyrics) => { - const duration = - index < lyrics.length - 1 ? lyrics[index + 1].time - verse.time : 3 - const unitDuration = duration / verse.text.length + const unitDuration = + (lyrics[index + 1].time - verse.time || 3) / verse.text.length let delay = 0 verse.words = verse.text.match(/\S+\s*/gu).map((text) => { const duration = text.length * unitDuration delay += duration - return { - duration, - delay, - text - } + return { duration, delay, text } }) }) } @@ -117,25 +114,25 @@ export default { } // Not found, then start a binary search let end = la.length - 1, - index = 0, + index = -1, start = 0 while (start <= end) { index = (start + end) >> 1 - const currentVerse = la[index] - const nextVerse = la[index + 1] + const currentVerseTime = la[index].time + const nextVerseTime = la[index + 1]?.time if ( - currentVerse.time <= currentTime && - (nextVerse?.time > currentTime || !nextVerse) + currentVerseTime <= currentTime && + (nextVerseTime > currentTime || !nextVerseTime) ) { - return index + break } - if (currentVerse.time < currentTime) { + if (currentVerseTime < currentTime) { start = index + 1 } else { end = index - 1 } } - return -1 + return index } this.reset_scrolling() return -1 @@ -175,13 +172,11 @@ export default { pane.scrollTop }) }, - start_scrolling(e) { + start_scrolling(event) { // Consider only user events - if (e.screenX || e.screenX !== 0 || e.screenY || e.screenY !== 0) { + if (event.screenX ?? event.screenY) { this.autoScrolling = false - if (this.scrollingTimer) { - clearTimeout(this.scrollingTimer) - } + clearTimeout(this.scrollingTimer) // Reenable automatic scrolling after 2 seconds this.scrollingTimer = setTimeout((this.autoScrolling = true), 2000) } diff --git a/web-src/src/components/ModalDialogPlaylistSave.vue b/web-src/src/components/ModalDialogPlaylistSave.vue index 16d399a3..4d033a10 100644 --- a/web-src/src/components/ModalDialogPlaylistSave.vue +++ b/web-src/src/components/ModalDialogPlaylistSave.vue @@ -74,8 +74,8 @@ export default { data() { return { disabled: true, - playlist_name: '', - loading: false + loading: false, + playlist_name: '' } }, diff --git a/web-src/src/components/NavbarBottom.vue b/web-src/src/components/NavbarBottom.vue index fa60e6bc..00b00261 100644 --- a/web-src/src/components/NavbarBottom.vue +++ b/web-src/src/components/NavbarBottom.vue @@ -103,7 +103,7 @@ @@ -114,7 +114,7 @@ export default { data() { return { artist: {}, - grouping_options: [ + groupings: [ { id: 1, name: this.$t('page.artist.sort.name'), @@ -150,7 +150,7 @@ export default { this.$store.commit(types.HIDE_SPOTIFY, value) } }, - selected_grouping_option_id: { + selected_grouping_id: { get() { return this.$store.state.artist_tracks_sort }, @@ -165,14 +165,13 @@ export default { return this.tracks_list.items.map((item) => item.uri).join() }, tracks() { - const grouping = this.grouping_options.find( - (o) => o.id === this.selected_grouping_option_id + const { options } = this.groupings.find( + (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (track) => !this.hide_spotify || track.data_kind !== 'spotify' ] - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PageArtists.vue b/web-src/src/pages/PageArtists.vue index e2acb071..5c29e211 100644 --- a/web-src/src/pages/PageArtists.vue +++ b/web-src/src/pages/PageArtists.vue @@ -41,8 +41,8 @@

@@ -101,7 +101,7 @@ export default { data() { return { artists_list: new GroupedList(), - grouping_options: [ + groupings: [ { id: 1, name: this.$t('page.artists.sort.name'), @@ -122,19 +122,15 @@ export default { computed: { // Wraps GroupedList and updates it if filter or sort changes artists() { - if (!this.artists_list) { - return [] - } - const grouping = this.grouping_options.find( - (o) => o.id === this.selected_grouping_option_id + const { options } = this.groupings.find( + (grouping) => grouping.id === this.selected_grouping_id ) - grouping.options.filters = [ + options.filters = [ (artist) => !this.hide_singles || artist.track_count > artist.album_count * 2, (artist) => !this.hide_spotify || artist.data_kind !== 'spotify' ] - this.artists_list.group(grouping.options) - return this.artists_list + return this.artists_list.group(options) }, hide_singles: { get() { @@ -152,7 +148,7 @@ export default { this.$store.commit(types.HIDE_SPOTIFY, value) } }, - selected_grouping_option_id: { + selected_grouping_id: { get() { return this.$store.state.artists_sort }, diff --git a/web-src/src/pages/PageComposerTracks.vue b/web-src/src/pages/PageComposerTracks.vue index d1361fb1..1fe9d021 100644 --- a/web-src/src/pages/PageComposerTracks.vue +++ b/web-src/src/pages/PageComposerTracks.vue @@ -7,8 +7,8 @@

@@ -102,7 +102,7 @@ export default { data() { return { composer: {}, - grouping_options: [ + groupings: [ { id: 1, name: this.$t('page.composer.sort.name'), @@ -126,7 +126,7 @@ export default { expression() { return `composer is "${this.composer.name}" and media_kind is music` }, - selected_grouping_option_id: { + selected_grouping_id: { get() { return this.$store.state.composer_tracks_sort }, @@ -135,11 +135,10 @@ export default { } }, tracks() { - const grouping = this.grouping_options.find( - (o) => o.id === this.selected_grouping_option_id + const { options } = this.groupings.find( + (grouping) => grouping.id === this.selected_grouping_id ) - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PageFiles.vue b/web-src/src/pages/PageFiles.vue index 02e42a72..794fc49a 100644 --- a/web-src/src/pages/PageFiles.vue +++ b/web-src/src/pages/PageFiles.vue @@ -125,7 +125,7 @@ export default { webapi.player_play_expression(this.play_expression, false) }, transform(path) { - return { path, name: path.slice(path.lastIndexOf('/') + 1) } + return { name: path.slice(path.lastIndexOf('/') + 1), path } } } } diff --git a/web-src/src/pages/PageGenreTracks.vue b/web-src/src/pages/PageGenreTracks.vue index 784c9c73..36e54d7d 100644 --- a/web-src/src/pages/PageGenreTracks.vue +++ b/web-src/src/pages/PageGenreTracks.vue @@ -7,8 +7,8 @@

@@ -97,7 +97,7 @@ export default { data() { return { genre: {}, - grouping_options: [ + groupings: [ { id: 1, name: this.$t('page.genre.sort.name'), @@ -122,7 +122,7 @@ export default { expression() { return `genre is "${this.genre.name}" and media_kind is ${this.media_kind}` }, - selected_grouping_option_id: { + selected_grouping_id: { get() { return this.$store.state.genre_tracks_sort }, @@ -131,11 +131,10 @@ export default { } }, tracks() { - const grouping = this.grouping_options.find( - (o) => o.id === this.selected_grouping_option_id + const { options } = this.groupings.find( + (grouping) => grouping.id === this.selected_grouping_id ) - this.tracks_list.group(grouping.options) - return this.tracks_list + return this.tracks_list.group(options) } }, diff --git a/web-src/src/pages/PageMusic.vue b/web-src/src/pages/PageMusic.vue index dbc3b430..f2547200 100644 --- a/web-src/src/pages/PageMusic.vue +++ b/web-src/src/pages/PageMusic.vue @@ -1,13 +1,12 @@ @@ -30,7 +30,7 @@ const dataObject = { }, set(vm, response) { - vm.recently_played = new GroupedList(response.data.tracks) + vm.tracks = new GroupedList(response.data.tracks) } } @@ -46,7 +46,7 @@ export default { data() { return { - recently_played: {} + tracks: {} } } } diff --git a/web-src/src/pages/PageMusicSpotify.vue b/web-src/src/pages/PageMusicSpotify.vue index f5485dd8..8e46abfd 100644 --- a/web-src/src/pages/PageMusicSpotify.vue +++ b/web-src/src/pages/PageMusicSpotify.vue @@ -1,13 +1,12 @@ @@ -32,7 +32,7 @@ const dataObject = { }, set(vm, response) { - vm.new_releases = response.albums.items + vm.albums = response.albums.items } } @@ -52,7 +52,7 @@ export default { data() { return { - new_releases: [] + albums: [] } } } diff --git a/web-src/src/pages/PageNowPlaying.vue b/web-src/src/pages/PageNowPlaying.vue index 31d4244f..e1012cef 100644 --- a/web-src/src/pages/PageNowPlaying.vue +++ b/web-src/src/pages/PageNowPlaying.vue @@ -76,8 +76,8 @@ export default { data() { return { - cursor: mdiCancel, INTERVAL, + cursor: mdiCancel, interval_id: 0, is_dragged: false, selected_item: {}, @@ -87,11 +87,11 @@ export default { computed: { composer() { - if (this.settings_option_show_composer_now_playing) { + if (this.setting_show_composer_now_playing) { if ( - !this.settings_option_show_composer_for_genre || + !this.setting_show_composer_for_genre || (this.track.genre && - this.settings_option_show_composer_for_genre + this.setting_show_composer_for_genre .toLowerCase() .split(',') .findIndex( @@ -105,7 +105,7 @@ export default { return null }, filepath() { - if (this.settings_option_show_filepath_now_playing) { + if (this.setting_show_filepath_now_playing) { return this.track.path } return null @@ -119,14 +119,14 @@ export default { player() { return this.$store.state.player }, - settings_option_show_composer_for_genre() { - return this.$store.getters.settings_option_show_composer_for_genre + setting_show_composer_for_genre() { + return this.$store.getters.setting_show_composer_for_genre }, - settings_option_show_composer_now_playing() { - return this.$store.getters.settings_option_show_composer_now_playing + setting_show_composer_now_playing() { + return this.$store.getters.setting_show_composer_now_playing }, - settings_option_show_filepath_now_playing() { - return this.$store.getters.settings_option_show_filepath_now_playing + setting_show_filepath_now_playing() { + return this.$store.getters.setting_show_filepath_now_playing }, track() { return this.$store.getters.now_playing diff --git a/web-src/src/pages/PagePlaylistFolder.vue b/web-src/src/pages/PagePlaylistFolder.vue index e2f55a5f..c2aafb08 100644 --- a/web-src/src/pages/PagePlaylistFolder.vue +++ b/web-src/src/pages/PagePlaylistFolder.vue @@ -66,7 +66,7 @@ export default { computed: { playlists() { - this.playlists_list.group({ + return this.playlists_list.group({ filters: [ (playlist) => playlist.folder || @@ -75,7 +75,6 @@ export default { playlist.item_count > playlist.stream_count ] }) - return this.playlists_list }, radio_playlists() { return this.$store.state.config.radio_playlists diff --git a/web-src/src/pages/PagePlaylistTracksSpotify.vue b/web-src/src/pages/PagePlaylistTracksSpotify.vue index 10d227b7..5917ef78 100644 --- a/web-src/src/pages/PagePlaylistTracksSpotify.vue +++ b/web-src/src/pages/PagePlaylistTracksSpotify.vue @@ -34,7 +34,9 @@ - +