[web] Avoid useless assignment

This commit is contained in:
Alain Nussbaumer 2024-04-25 21:33:38 +02:00
parent 938458b56e
commit 30fc35097c
2 changed files with 8 additions and 9 deletions

View File

@ -32,7 +32,6 @@ export default [
'no-ternary': 'off', 'no-ternary': 'off',
'no-undef': 'off', 'no-undef': 'off',
'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }], 'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none' }],
'no-useless-assignment': 'off',
'one-var': 'off', 'one-var': 'off',
'prefer-named-capture-group': 'off', 'prefer-named-capture-group': 'off',
'sort-keys': 'off', 'sort-keys': 'off',

View File

@ -117,25 +117,25 @@ export default {
} }
// Not found, then start a binary search // Not found, then start a binary search
let end = la.length - 1, let end = la.length - 1,
index = 0, index = -1,
start = 0 start = 0
while (start <= end) { while (start <= end) {
index = (start + end) >> 1 index = (start + end) >> 1
const currentVerse = la[index] const currentVerseTime = la[index].time
const nextVerse = la[index + 1] const nextVerseTime = la[index + 1]?.time
if ( if (
currentVerse.time <= currentTime && currentVerseTime <= currentTime &&
(nextVerse?.time > currentTime || !nextVerse) (nextVerseTime > currentTime || !nextVerseTime)
) { ) {
return index break
} }
if (currentVerse.time < currentTime) { if (currentVerseTime < currentTime) {
start = index + 1 start = index + 1
} else { } else {
end = index - 1 end = index - 1
} }
} }
return -1 return index
} }
this.reset_scrolling() this.reset_scrolling()
return -1 return -1