Skip to content

Commit

Permalink
messagegui: fix mapping select to correct message
Browse files Browse the repository at this point in the history
  • Loading branch information
thyttan committed Jan 2, 2025
1 parent e083508 commit 7dbdc18
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions apps/messagegui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
}

var lines = [];
lines = g.wrapString(msgLocal.title||msgLocal.sender||msgLocal.subject||msgLocal.src||"No Title", g.getWidth()-10);
const TITLE_STRING = "".concat(msgLocal.title, msgLocal.title&&"\n",
msgLocal.sender, msgLocal.sender&&"\n", msgLocal.subject,
msgLocal.subject&&"\n", msgLocal.src) || "No Title";
lines = g.wrapString(TITLE_STRING, g.getWidth()-10);
for (let i=0; i<lines.length; i++) {
titleLines.push(i + (messagesWrapped[0]?messagesWrapped[0].length:0) +
(messagesWrapped[1]?messagesWrapped[1].length:0));
Expand Down Expand Up @@ -368,8 +371,12 @@ function showMessagesScroller(msg, persist, alreadyProcessed) {
prevScrollIdx = scrollIdx;
}, select : function(scrollIdx, touch) {
let msgSelect;
for (let i = titleLines.length-1; i>=0 ; i--) {
if (scrollIdx>=titleLines[i]) {
let titleLinesInitials = [titleLines[0]];
for (let i=1; i<titleLines.length; i++) {
if (titleLines[i]-titleLines[i-1] > 1) {titleLinesInitials.push(titleLines[i]);}
}
for (let i=titleLines.length-1; i>=0 ; i--) {
if (scrollIdx>=titleLinesInitials[i]) {
msgSelect = MESSAGES[i + updatedProcessed.startIdx];
break;
}
Expand Down

0 comments on commit 7dbdc18

Please sign in to comment.