Skip to content

messagegui: Fix bugs related to empty titles and bodies. #3972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/messagegui/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,5 @@
Remove workaround for 2v10 (>3 years ago) - assume everyone is on never firmware now
0.86: Default to showing message scroller (with title, bigger icon)
0.87: Make choosing of font size more repeatable
0.88: Adjust padding calculation so messages are spaced out properly even when using international fonts
0.88: Adjust padding calculation so messages are spaced out properly even when using international fonts
0.89: Fix bugs related to empty titles and bodies
8 changes: 5 additions & 3 deletions apps/messagegui/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ function showMessage(msgid, persist) {
active = "message";
// Normal text message display
let src=msg.src||/*LANG*/"Message", srcFont = fontSmall;
let title=msg.title, titleFont = fontLarge, lines;
let title=msg.title||"", titleFont = fontLarge, lines=[];
let body=msg.body, bodyFont = fontLarge;
// If no body, use the title text instead...
if (body===undefined) {
if (!body) {
body = title;
title = undefined;
title = "";
}
if (g.setFont(srcFont).stringWidth(src) > g.getWidth()-52)
srcFont = "4x6";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! To avoid a future regression, perhaps we comment about the relation here?

Suggested change
srcFont = "4x6";
srcFont = "4x6";
// one of `title` or `body` must be truthy at this point (#3969)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added another commit with a comment. I wrote it differently, because the total set of issues ended up being not just about truthiness but variables being undefined yet referenced later.

Expand All @@ -392,6 +392,8 @@ function showMessage(msgid, persist) {
}
lines = g.setFont(bodyFont).wrapString(body, w);
}
// By this point, `title` must be a string and `lines` must be an array of strings.
// Either or both can be empty, but neither can be `undefined` (#3969).
let negHandler,posHandler,rowLeftDraw,rowRightDraw;
if (msg.negative) {
negHandler = ()=>{
Expand Down
2 changes: 1 addition & 1 deletion apps/messagegui/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "messagegui",
"name": "Message UI",
"shortName": "Messages",
"version": "0.88",
"version": "0.89",
"description": "Default app to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png",
"type": "app",
Expand Down