From 6c801bd8bfa67b976ab02bab837e45170c6b0be0 Mon Sep 17 00:00:00 2001 From: Randy Heydon Date: Thu, 21 Aug 2025 21:07:33 -0400 Subject: [PATCH 1/2] messagegui: Fix bugs related to empty titles and bodies. Fixes #3969. Notification events can now have title or body as empty strings or `undefined` without errors. Tested from console using the below notification messages sent from console. Prior to this commit, all but the two marked test messages created errors. GB({"t":"notify", "id":987123, "title":"Title"}) GB({"t":"notify", "id":987124, "title":"Title", "body":""}) GB({"t":"notify", "id":987125, "body":"Body"}) GB({"t":"notify", "id":987126, "title":"", "body":"Body"}) // worked before this commit GB({"t":"notify", "id":987127, "title":""}) GB({"t":"notify", "id":987128, "body":""}) GB({"t":"notify", "id":987129}) // does nothing --- apps/messagegui/ChangeLog | 3 ++- apps/messagegui/app.js | 6 +++--- apps/messagegui/metadata.json | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/messagegui/ChangeLog b/apps/messagegui/ChangeLog index d849e9b6fd..48d5234fe9 100644 --- a/apps/messagegui/ChangeLog +++ b/apps/messagegui/ChangeLog @@ -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 \ No newline at end of file +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 diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index 7dcfec866d..fff03e5cce 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -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"; diff --git a/apps/messagegui/metadata.json b/apps/messagegui/metadata.json index db54edb7e8..8ef38bd063 100644 --- a/apps/messagegui/metadata.json +++ b/apps/messagegui/metadata.json @@ -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", From e3394ccd55791a47ee9e2f809ed131026ae7e56f Mon Sep 17 00:00:00 2001 From: Randy Heydon Date: Fri, 22 Aug 2025 19:33:58 -0400 Subject: [PATCH 2/2] messagegui: Comment expected values of variables. --- apps/messagegui/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/messagegui/app.js b/apps/messagegui/app.js index fff03e5cce..5b30957304 100644 --- a/apps/messagegui/app.js +++ b/apps/messagegui/app.js @@ -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 = ()=>{