Skip to content

Commit 1c19b13

Browse files
author
thyttan
committed
messagegui: tweak updateReadMessages, possibly fixing off by one
1 parent a896cf3 commit 1c19b13

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

apps/messagegui/app.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,25 @@ function showMessagesScroller(msg, persist) {
373373
//print(shownIdxFirst, shownIdxLast)
374374

375375
for (let i=0; i<firstTitleLinePerMsg.length-1 ; i++) {
376-
377-
if (shownScrollIdxFirst<=firstTitleLinePerMsg[i] && shownScrollIdxFirst+LINES_PER_SCREEN>firstTitleLinePerMsg[i]) {
376+
const FIRST_LINE_OF_MSG = firstTitleLinePerMsg[i];
377+
const LAST_LINE_OF_MSG = firstTitleLinePerMsg[i+1]-1;
378+
379+
if (
380+
shownScrollIdxFirst
381+
<= FIRST_LINE_OF_MSG && FIRST_LINE_OF_MSG
382+
< shownScrollIdxFirst+LINES_PER_SCREEN
383+
) {
378384
shownMsgIdxFirst = i;
379385
}
380386

381-
if (shownScrollIdxLast>=firstTitleLinePerMsg[i+1] && shownScrollIdxLast-LINES_PER_SCREEN<firstTitleLinePerMsg[i+1]) {
387+
if (
388+
shownScrollIdxLast-LINES_PER_SCREEN
389+
< LAST_LINE_OF_MSG && LAST_LINE_OF_MSG
390+
<= shownScrollIdxLast
391+
) {
382392
shownMsgIdxLast = i;
383393
//print(i)
384394
}
385-
386395
}
387396
if (shownScrollIdxLast===allLines.length-1) {shownMsgIdxLast = MESSAGES.length-1;}
388397

0 commit comments

Comments
 (0)