Skip to content

Commit 7dbdc18

Browse files
author
thyttan
committed
messagegui: fix mapping select to correct message
1 parent e083508 commit 7dbdc18

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/messagegui/app.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,10 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
297297
}
298298

299299
var lines = [];
300-
lines = g.wrapString(msgLocal.title||msgLocal.sender||msgLocal.subject||msgLocal.src||"No Title", g.getWidth()-10);
300+
const TITLE_STRING = "".concat(msgLocal.title, msgLocal.title&&"\n",
301+
msgLocal.sender, msgLocal.sender&&"\n", msgLocal.subject,
302+
msgLocal.subject&&"\n", msgLocal.src) || "No Title";
303+
lines = g.wrapString(TITLE_STRING, g.getWidth()-10);
301304
for (let i=0; i<lines.length; i++) {
302305
titleLines.push(i + (messagesWrapped[0]?messagesWrapped[0].length:0) +
303306
(messagesWrapped[1]?messagesWrapped[1].length:0));
@@ -368,8 +371,12 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
368371
prevScrollIdx = scrollIdx;
369372
}, select : function(scrollIdx, touch) {
370373
let msgSelect;
371-
for (let i = titleLines.length-1; i>=0 ; i--) {
372-
if (scrollIdx>=titleLines[i]) {
374+
let titleLinesInitials = [titleLines[0]];
375+
for (let i=1; i<titleLines.length; i++) {
376+
if (titleLines[i]-titleLines[i-1] > 1) {titleLinesInitials.push(titleLines[i]);}
377+
}
378+
for (let i=titleLines.length-1; i>=0 ; i--) {
379+
if (scrollIdx>=titleLinesInitials[i]) {
373380
msgSelect = MESSAGES[i + updatedProcessed.startIdx];
374381
break;
375382
}

0 commit comments

Comments
 (0)