From 30fc35097ca0a656b28ac0a7ecadc686a02a1448 Mon Sep 17 00:00:00 2001 From: Alain Nussbaumer Date: Thu, 25 Apr 2024 21:33:38 +0200 Subject: [PATCH] [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