From 938458b56e87d4cc98879cbc1c680ec5f6e0a771 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 25 Apr 2024 21:33:01 +0200 Subject: [PATCH 01/20] [web] Remove unused arguments --- web-src/src/store/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web-src/src/store/index.js b/web-src/src/store/index.js index 29e775f6..b6da6636 100644 --- a/web-src/src/store/index.js +++ b/web-src/src/store/index.js @@ -179,7 +179,7 @@ export default createStore({ }, actions: { - add_notification({ commit, state }, notification) { + add_notification({ state }, notification) { const newNotification = { id: state.notifications.next_id++, text: notification.text, @@ -203,7 +203,7 @@ export default createStore({ }, notification.timeout) } }, - add_recent_search({ commit, state }, query) { + add_recent_search({ state }, query) { const index = state.recent_searches.indexOf(query) if (index !== -1) { state.recent_searches.splice(index, 1) @@ -213,19 +213,19 @@ export default createStore({ state.recent_searches.pop() } }, - delete_notification({ commit, state }, notification) { + delete_notification({ state }, notification) { const index = state.notifications.list.indexOf(notification) if (index !== -1) { state.notifications.list.splice(index, 1) } }, - remove_recent_search({ commit, state }, query) { + remove_recent_search({ state }, query) { const index = state.recent_searches.indexOf(query) if (index !== -1) { state.recent_searches.splice(index, 1) } }, - update_settings_option({ commit, state }, option) { + update_settings_option({ state }, option) { const settingCategory = state.settings.categories.find( (e) => e.name === option.category ), From 30fc35097ca0a656b28ac0a7ecadc686a02a1448 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 25 Apr 2024 21:33:38 +0200 Subject: [PATCH 02/20] [web] Avoid useless assignment --- web-src/eslint.config.js | 1 - web-src/src/components/LyricsPane.vue | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/web-src/eslint.config.js b/web-src/eslint.config.js index e25aed9f..86a16ba6 100644 --- a/web-src/eslint.config.js +++ b/web-src/eslint.config.js @@ -32,7 +32,6 @@ export default [ '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', diff --git a/web-src/src/components/LyricsPane.vue b/web-src/src/components/LyricsPane.vue index 2b555cad..8e42a351 100644 --- a/web-src/src/components/LyricsPane.vue +++ b/web-src/src/components/LyricsPane.vue @@ -117,25 +117,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 From 73040780b9016afdbd41adca0730f96bf7acb1ac Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 25 Apr 2024 22:36:04 +0200 Subject: [PATCH 03/20] [web] Remove unnecessary word option --- web-src/src/components/ListAlbums.vue | 2 +- web-src/src/components/ListAlbumsSpotify.vue | 2 +- web-src/src/components/NavbarTop.vue | 26 +++++++------------ web-src/src/components/SettingsCheckbox.vue | 4 +-- web-src/src/components/SettingsIntfield.vue | 23 ++++------------ web-src/src/components/SettingsTextfield.vue | 23 ++++------------ web-src/src/pages/PageMusicRecentlyAdded.vue | 2 +- web-src/src/pages/PageNowPlaying.vue | 20 +++++++------- .../src/pages/PageSettingsWebinterface.vue | 10 +++---- web-src/src/store/index.js | 12 ++++----- 10 files changed, 46 insertions(+), 78 deletions(-) diff --git a/web-src/src/components/ListAlbums.vue b/web-src/src/components/ListAlbums.vue index c674b52c..9fee1572 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 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/NavbarTop.vue b/web-src/src/components/NavbarTop.vue index ef7f77c8..42257041 100644 --- a/web-src/src/components/NavbarTop.vue +++ b/web-src/src/components/NavbarTop.vue @@ -138,7 +138,7 @@ export default { } }, show_audiobooks() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_menu_item_audiobooks' ).value @@ -152,40 +152,34 @@ export default { } }, show_files() { - return this.$store.getters.settings_option( - 'webinterface', - 'show_menu_item_files' - ).value + return this.$store.getters.setting('webinterface', 'show_menu_item_files') + .value }, show_music() { - return this.$store.getters.settings_option( - 'webinterface', - 'show_menu_item_music' - ).value + return this.$store.getters.setting('webinterface', 'show_menu_item_music') + .value }, show_player_menu() { return this.$store.state.show_player_menu }, show_playlists() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_menu_item_playlists' ).value }, show_podcasts() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_menu_item_podcasts' ).value }, show_radio() { - return this.$store.getters.settings_option( - 'webinterface', - 'show_menu_item_radio' - ).value + return this.$store.getters.setting('webinterface', 'show_menu_item_radio') + .value }, show_search() { - return this.$store.getters.settings_option( + return this.$store.getters.setting( 'webinterface', 'show_menu_item_search' ).value diff --git a/web-src/src/components/SettingsCheckbox.vue b/web-src/src/components/SettingsCheckbox.vue index b4f306be..5feb1970 100644 --- a/web-src/src/components/SettingsCheckbox.vue +++ b/web-src/src/components/SettingsCheckbox.vue @@ -55,7 +55,7 @@ export default { return this.statusUpdate === 'success' }, option() { - const option = this.$store.getters.settings_option( + const option = this.$store.getters.setting( this.category_name, this.option_name ) @@ -87,7 +87,7 @@ export default { webapi .settings_update(this.category_name, option) .then(() => { - this.$store.dispatch('update_settings_option', option) + this.$store.dispatch('update_setting', option) this.statusUpdate = 'success' }) .catch(() => { diff --git a/web-src/src/components/SettingsIntfield.vue b/web-src/src/components/SettingsIntfield.vue index 9e0aec93..b2f83d2f 100644 --- a/web-src/src/components/SettingsIntfield.vue +++ b/web-src/src/components/SettingsIntfield.vue @@ -16,7 +16,7 @@ inputmode="numeric" min="0" :placeholder="placeholder" - :value="value" + :value="option.value" @input="set_update_timer" /> @@ -48,11 +48,6 @@ export default { }, computed: { - category() { - return this.$store.state.settings.categories.find( - (elem) => elem.name === this.category_name - ) - }, info() { if (this.statusUpdate === 'success') { return this.$t('setting.saved') @@ -68,15 +63,7 @@ export default { return this.statusUpdate === 'success' }, option() { - if (!this.category) { - return {} - } - return this.category.options.find( - (elem) => elem.name === this.option_name - ) - }, - value() { - return this.option.value + return this.$store.getters.setting(this.category_name, this.option_name) } }, @@ -101,14 +88,14 @@ export default { return } const option = { - category: this.category.name, + category: this.category_name, name: this.option_name, value: newValue } webapi - .settings_update(this.category.name, option) + .settings_update(this.category_name, option) .then(() => { - this.$store.dispatch('update_settings_option', option) + this.$store.dispatch('update_setting', option) this.statusUpdate = 'success' }) .catch(() => { diff --git a/web-src/src/components/SettingsTextfield.vue b/web-src/src/components/SettingsTextfield.vue index cd7618f0..b5a778fe 100644 --- a/web-src/src/components/SettingsTextfield.vue +++ b/web-src/src/components/SettingsTextfield.vue @@ -15,7 +15,7 @@ class="input" type="text" :placeholder="placeholder" - :value="value" + :value="option.value" @input="set_update_timer" /> @@ -47,11 +47,6 @@ export default { }, computed: { - category() { - return this.$store.state.settings.categories.find( - (elem) => elem.name === this.category_name - ) - }, info() { if (this.statusUpdate === 'success') { return this.$t('setting.saved') @@ -67,15 +62,7 @@ export default { return this.statusUpdate === 'success' }, option() { - if (!this.category) { - return {} - } - return this.category.options.find( - (elem) => elem.name === this.option_name - ) - }, - value() { - return this.option.value + return this.$store.getters.setting(this.category_name, this.option_name) } }, @@ -102,14 +89,14 @@ export default { return } const option = { - category: this.category.name, + category: this.category_name, name: this.option_name, value: newValue } webapi - .settings_update(this.category.name, option) + .settings_update(this.category_name, option) .then(() => { - this.$store.dispatch('update_settings_option', option) + this.$store.dispatch('update_setting', option) this.statusUpdate = 'success' }) .catch(() => { diff --git a/web-src/src/pages/PageMusicRecentlyAdded.vue b/web-src/src/pages/PageMusicRecentlyAdded.vue index 2de6f9cf..b1563a34 100644 --- a/web-src/src/pages/PageMusicRecentlyAdded.vue +++ b/web-src/src/pages/PageMusicRecentlyAdded.vue @@ -22,7 +22,7 @@ import webapi from '@/webapi' const dataObject = { load(to) { - const limit = store.getters.settings_option_recently_added_limit + const limit = store.getters.setting_recently_added_limit return webapi.search({ expression: 'media_kind is music having track_count > 3 order by time_added desc', diff --git a/web-src/src/pages/PageNowPlaying.vue b/web-src/src/pages/PageNowPlaying.vue index 31d4244f..842fad86 100644 --- a/web-src/src/pages/PageNowPlaying.vue +++ b/web-src/src/pages/PageNowPlaying.vue @@ -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/PageSettingsWebinterface.vue b/web-src/src/pages/PageSettingsWebinterface.vue index 1a507192..79409f7b 100644 --- a/web-src/src/pages/PageSettingsWebinterface.vue +++ b/web-src/src/pages/PageSettingsWebinterface.vue @@ -123,7 +123,7 @@