messages 0.48: When getting new message from the clock, only buzz once the messages app is loaded

master
Gordon Williams 2022-07-22 11:23:21 +01:00
parent e071978335
commit f70ccd5aea
5 changed files with 27 additions and 13 deletions

View File

@ -61,3 +61,4 @@
0.46: Add 'Vibrate Timer' option to set how long to vibrate for, and fix Repeat:off 0.46: Add 'Vibrate Timer' option to set how long to vibrate for, and fix Repeat:off
Fix message removal from widget bar (previously caused exception as .hide has been removed) Fix message removal from widget bar (previously caused exception as .hide has been removed)
0.47: Add new Icons (Nextbike, Mattermost, etc.) 0.47: Add new Icons (Nextbike, Mattermost, etc.)
0.48: When getting new message from the clock, only buzz once the messages app is loaded

View File

@ -0,0 +1,5 @@
/* Called when we have a new message when we're in the clock...
BUZZ_ON_NEW_MESSAGE is set so when messages.app.js loads it knows
that it should buzz */
global.BUZZ_ON_NEW_MESSAGE = true;
eval(require("Storage").read("messages.app.js"));

View File

@ -353,8 +353,18 @@ function checkMessages(options) {
// we have >0 messages // we have >0 messages
var newMessages = MESSAGES.filter(m=>m.new&&m.id!="music"); var newMessages = MESSAGES.filter(m=>m.new&&m.id!="music");
// If we have a new message, show it // If we have a new message, show it
if (options.showMsgIfUnread && newMessages.length) if (options.showMsgIfUnread && newMessages.length) {
return showMessage(newMessages[0].id); showMessage(newMessages[0].id);
// buzz after showMessage, so beingbusy during layout doesn't affect the buzz pattern
if (global.BUZZ_ON_NEW_MESSAGE) {
// this is set if we entered the messages app by loading `messages.new.js`
// ... but only buzz the first time we view a new message
global.BUZZ_ON_NEW_MESSAGE = false;
// messages.buzz respects quiet mode - no need to check here
WIDGETS.messages.buzz(newMessages[0].src);
}
return;
}
// no new messages: show playing music? (only if we have playing music to show) // no new messages: show playing music? (only if we have playing music to show)
if (options.openMusic && MESSAGES.some(m=>m.id=="music" && m.track && m.state=="play")) if (options.openMusic && MESSAGES.some(m=>m.id=="music" && m.track && m.state=="play"))
return showMessage('music'); return showMessage('music');

View File

@ -68,23 +68,20 @@ exports.pushMessage = function(event) {
if(quiet && quietNoAutOpn) { if(quiet && quietNoAutOpn) {
loadMessages = false; loadMessages = false;
} }
// first, buzz
if (!quiet && loadMessages && global.WIDGETS && WIDGETS.messages){
WIDGETS.messages.buzz(event.src);
if(unlockWatch != false){
Bangle.setLocked(false);
Bangle.setLCDPower(1); // turn screen on
}
}
// after a delay load the app, to ensure we have all the messages // after a delay load the app, to ensure we have all the messages
if (exports.messageTimeout) clearTimeout(exports.messageTimeout); if (exports.messageTimeout) clearTimeout(exports.messageTimeout);
exports.messageTimeout = setTimeout(function() { exports.messageTimeout = setTimeout(function() {
exports.messageTimeout = undefined; exports.messageTimeout = undefined;
// if we're in a clock or it's important, go straight to messages app // if we're in a clock or it's important, go straight to messages app
if (loadMessages){ if (loadMessages){
return load("messages.app.js"); if(!quiet && unlockWatch){
Bangle.setLocked(false);
Bangle.setLCDPower(1); // turn screen on
} }
if (!quiet && (!global.WIDGETS || !WIDGETS.messages)) return Bangle.buzz(); // no widgets - just buzz to let someone know // we will buzz when we enter the messages app
return load("messages.new.js");
}
if (!quiet && (!global.WIDGETS || !WIDGETS.messages)) return Bangle.buzz(); // no widgets - just buzz once to let someone know
if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.update(messages); if (global.WIDGETS && WIDGETS.messages) WIDGETS.messages.update(messages);
}, 500); }, 500);
} }

View File

@ -1,7 +1,7 @@
{ {
"id": "messages", "id": "messages",
"name": "Messages", "name": "Messages",
"version": "0.47", "version": "0.48",
"description": "App to display notifications from iOS and Gadgetbridge/Android", "description": "App to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",
@ -10,6 +10,7 @@
"readme": "README.md", "readme": "README.md",
"storage": [ "storage": [
{"name":"messages.app.js","url":"app.js"}, {"name":"messages.app.js","url":"app.js"},
{"name":"messages.new.js","url":"app-newmessage.js"},
{"name":"messages.settings.js","url":"settings.js"}, {"name":"messages.settings.js","url":"settings.js"},
{"name":"messages.img","url":"app-icon.js","evaluate":true}, {"name":"messages.img","url":"app-icon.js","evaluate":true},
{"name":"messages.wid.js","url":"widget.js"}, {"name":"messages.wid.js","url":"widget.js"},