diff --git a/apps/msgwakefup/ChangeLog b/apps/msgwakefup/ChangeLog index 5560f00bc..7428ca428 100644 --- a/apps/msgwakefup/ChangeLog +++ b/apps/msgwakefup/ChangeLog @@ -1 +1,3 @@ 0.01: New App! +0.02: Update to work better with new version of messagegui when fastload utils + is also installed. diff --git a/apps/msgwakefup/boot.js b/apps/msgwakefup/boot.js index f30de7a1b..33c162b99 100644 --- a/apps/msgwakefup/boot.js +++ b/apps/msgwakefup/boot.js @@ -1,9 +1,32 @@ +{ +let attach = ()=>{ + if (global.__FILE__=="messagegui.new.js") Bangle.setOptions({wakeOnFaceUp:true}); + + // Give messagegui some extra time to add its remove function to + // Bangle.uiRemove, then attach msgtwscr remove logic. + setTimeout( + ()=>{if (Bangle.uiRemove) { + let showMessageUIRemove = Bangle.uiRemove; + Bangle.uiRemove = function () { + Bangle.setOptions({wakeOnFaceUp:false}); + showMessageUIRemove(); + attachAfterTimeout(); + } + }}, + 850) +} + +let attachAfterTimeout = ()=>{ + setTimeout(()=>{ + attach(); + },700) // It feels like there's a more elegant solution than checking the filename after 700 milliseconds. But this at least seems to work w/o sometimes activating when it shouldn't. +} + // If doing regular loads, not Bangle.load, this is used: -if (global.__FILE__=="messagegui.new.js") Bangle.setOptions({wakeOnFaceUp:true}); +if (global.__FILE__=="messagegui.new.js") attach(); // If Fastload Utils is installed this is used: Bangle.on("message", (_, msg)=>{if (Bangle.CLOCK && msg.new) { - setTimeout(()=>{ - if (global.__FILE__=="messagegui.new.js") Bangle.setOptions({wakeOnFaceUp:true}); - },700) // It feels like there's a more elegant solution than checking the filename after 700 milliseconds. But this at least seems to work w/o sometimes activating when it shouldn't. + attachAfterTimeout(); }}); +} diff --git a/apps/msgwakefup/metadata.json b/apps/msgwakefup/metadata.json index 7f97b3221..857bebc0a 100644 --- a/apps/msgwakefup/metadata.json +++ b/apps/msgwakefup/metadata.json @@ -1,6 +1,6 @@ { "id": "msgwakefup", "name": "Message wake on face up", - "version":"0.01", + "version":"0.02", "description": "Temporarily activate wake on face up function when a new message is auto displayed.", "icon": "app.png", "tags": "messages,tweak",