Merge pull request #1123 from nebbishhacker/messages

messages: Hide widget when all unread messages are dismissed
master
Gordon Williams 2021-12-17 09:15:54 +00:00 committed by GitHub
commit d848871a7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -77,7 +77,7 @@
{ {
"id": "messages", "id": "messages",
"name": "Messages", "name": "Messages",
"version": "0.13", "version": "0.14",
"description": "App to display notifications from iOS and Gadgetbridge", "description": "App to display notifications from iOS and Gadgetbridge",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",

View File

@ -20,3 +20,4 @@
0.13: Add /*LANG*/ comments for internationalisation 0.13: Add /*LANG*/ comments for internationalisation
Add 'Delete All' option to message options Add 'Delete All' option to message options
Now update correctly when 'require("messages").clearAll()' is called Now update correctly when 'require("messages").clearAll()' is called
0.14: Hide widget when all unread notifications are dismissed from phone

View File

@ -30,6 +30,10 @@ exports.pushMessage = function(event) {
require("Storage").writeJSON("messages.json",messages); require("Storage").writeJSON("messages.json",messages);
// if in app, process immediately // if in app, process immediately
if (inApp) return onMessagesModified(mIdx<0 ? {id:event.id} : messages[mIdx]); if (inApp) return onMessagesModified(mIdx<0 ? {id:event.id} : messages[mIdx]);
// if we've removed the last new message, hide the widget
if (event.t=="remove" && !messages.some(m=>m.new)) {
if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.hide();
}
// ok, saved now - we only care if it's new // ok, saved now - we only care if it's new
if (event.t!="add") { if (event.t!="add") {
return; return;