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

Conversation

randyheydon
Copy link
Contributor

Fixes #3969. Notification events can now have title or body as empty strings or undefined without errors. Tested using the below notification messages sent from console. Prior to this commit, all but the two marked test messages created errors. Also tested with actual task notifications from Android.

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

Fixes espruino#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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[messagegui] Blank on task items with short titles
2 participants