From 7826b366349a3faa02b6a5f79444341f0a39bcb3 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Fri, 26 Apr 2024 21:48:07 +0200 Subject: [PATCH] [web] Fix shadowed variables --- web-src/eslint.config.js | 1 - web-src/src/components/ListAlbums.vue | 6 +++--- web-src/src/components/LyricsPane.vue | 11 +++-------- web-src/src/lib/GroupedList.js | 6 +++--- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/web-src/eslint.config.js b/web-src/eslint.config.js index 86a16ba6..31c88d04 100644 --- a/web-src/eslint.config.js +++ b/web-src/eslint.config.js @@ -28,7 +28,6 @@ export default [ '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' }], diff --git a/web-src/src/components/ListAlbums.vue b/web-src/src/components/ListAlbums.vue index 9fee1572..2333bfa7 100644 --- a/web-src/src/components/ListAlbums.vue +++ b/web-src/src/components/ListAlbums.vue @@ -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/LyricsPane.vue b/web-src/src/components/LyricsPane.vue index 4b8dc756..68dc90a5 100644 --- a/web-src/src/components/LyricsPane.vue +++ b/web-src/src/components/LyricsPane.vue @@ -68,18 +68,13 @@ export default { }) // 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 } }) }) } diff --git a/web-src/src/lib/GroupedList.js b/web-src/src/lib/GroupedList.js index 19155398..284e4b6d 100644 --- a/web-src/src/lib/GroupedList.js +++ b/web-src/src/lib/GroupedList.js @@ -80,7 +80,6 @@ export class GroupedList { } group({ criteria = [], filters = [], index } = {}) { - const indexer = createIndexer(index) const itemsFiltered = this.items.filter((item) => filters.every((filter) => filter(item)) ) @@ -94,9 +93,10 @@ export class GroupedList { ) ) // Group item list + const indexer = createIndexer(index) this.itemsGrouped = itemsSorted.reduce((map, item) => { - const index = indexer(item) - map.set(index, [...(map.get(index) || []), item]) + const key = indexer(item) + map.set(key, [...(map.get(key) || []), item]) return map }, new Map()) // Create index list