Skip to content

Commit e391f31

Browse files
author
thyttan
committed
messagegui: tweak logic re persist/unread timeout
e.g. move logic from the `showMessagesScroller` and `showMessageOverview` functions into `showMessageRouter`.
1 parent 27d178c commit e391f31

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

apps/messagegui/app.js

+12-15
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function showMessageRouter(msg, persist, explicitDestnation) {
107107
////var active; // active screen (undefined/"list"/"music"/"map"/"overview"/"scroller"/"settings")
108108
//if (active==undefined) { } else if (active=="list") ... //and so on.
109109

110-
if (persist) {cancelReloadTimeout();}
110+
if (persist) {cancelReloadTimeout();} else if (Bangle.isLocked()) {resetReloadTimeout();}
111111

112112
if (msg.id=="music") {
113113
cancelReloadTimeout(); // don't auto-reload to clock now
@@ -118,16 +118,16 @@ function showMessageRouter(msg, persist, explicitDestnation) {
118118
return showMapMessage(msg);
119119
}
120120
if (msg.id=="call") {
121-
return showMessageOverview(msg.id, persist);
121+
return showMessageOverview(msg.id);
122122
}
123123
if ("scroller"===explicitDestnation) {
124-
return showMessagesScroller(msg, persist);
124+
return showMessagesScroller(msg);
125125
}
126126
if ("overview"===explicitDestnation) {
127-
return showMessageOverview(msg.id, persist);
127+
return showMessageOverview(msg.id);
128128
}
129129
if ("dependsOnActive"===explicitDestnation) {
130-
if ("scroller"===active) {return showMessagesScroller(msg, persist);} // reinit scroller with updated messages list.
130+
if ("scroller"===active) {return showMessagesScroller(msg);} // reinit scroller with updated messages list.
131131
if ("list"===active) {return returnToMain();}
132132
if ("settings"===active || "overview"===active) {return;}
133133
}
@@ -281,13 +281,11 @@ function showMusicMessage(msg) {
281281
}, 400);
282282
}
283283

284-
function showMessagesScroller(msg, persist) {
285-
if (persist===undefined) {persist = true;}
284+
function showMessagesScroller(msg) {
286285
const MSG_IDX = msg ? MESSAGES.findIndex((m)=>m.id==msg.id) : undefined;
287286

288287
if (replying) { return; }
289288
active = "scroller";
290-
if (persist) {cancelReloadTimeout();} else {resetReloadTimeout();}
291289

292290
const WU = require("widget_utils");
293291
WU.hide();
@@ -408,7 +406,7 @@ function showMessageSettings(msg) {
408406
active = "settings";
409407
var menu = {"":{
410408
"title":/*LANG*/"Message",
411-
back:() => showMessageOverview(msg.id, true)
409+
back:() => showMessageOverview(msg.id)
412410
},
413411
};
414412

@@ -470,9 +468,8 @@ function showMessageSettings(msg) {
470468
E.showMenu(menu);
471469
}
472470

473-
function showMessageOverview(msgid, persist) {
471+
function showMessageOverview(msgid) {
474472
if (replying) { return; }
475-
if(!persist) resetReloadTimeout();
476473
let idx = MESSAGES.findIndex(m=>m.id==msgid);
477474
var msg = MESSAGES[idx];
478475
if (updateLabelsInterval) {
@@ -586,8 +583,8 @@ function showMessageOverview(msgid, persist) {
586583
Bangle.swipeHandler = (lr,ud) => {
587584
if (lr>0 && posHandler) posHandler();
588585
if (lr<0 && negHandler) negHandler();
589-
if (ud>0 && idx<MESSAGES.length-1) showMessageOverview(MESSAGES[idx+1].id, true);
590-
if (ud<0 && idx>0) showMessageOverview(MESSAGES[idx-1].id, true);
586+
if (ud>0 && idx<MESSAGES.length-1) showMessageOverview(MESSAGES[idx+1].id);
587+
if (ud<0 && idx>0) showMessageOverview(MESSAGES[idx-1].id);
591588
};
592589
Bangle.on("swipe", Bangle.swipeHandler);
593590
g.reset().clearRect(Bangle.appRect);
@@ -624,7 +621,7 @@ function checkMessages(options) {
624621
// If we have a new message, show it
625622
if (!options.ignoreUnread && newMessages.length) {
626623
delete newMessages[0].show; // stop us getting stuck here if we're called a second time
627-
showMessagesScroller(newMessages[0], persist);
624+
showMessagesScroller(newMessages[0]);
628625
// buzz after showMessagesScroller, so being busy during scroller setup doesn't affect the buzz pattern
629626
if (globalThis.BUZZ_ON_NEW_MESSAGE) {
630627
// this is set if we entered the messages app by loading `messagegui.new.js`
@@ -637,7 +634,7 @@ function checkMessages(options) {
637634
}
638635
// no new messages: show playing music? Only if we have playing music, or state=="show" (set by messagesmusic)
639636
if (options.openMusic && MESSAGES.some(m=>m.id=="music" && ((m.track && m.state=="play") || m.state=="show")))
640-
return showMessageOverview('music', true);
637+
return showMessageOverview('music');
641638
// no new messages - go to clock?
642639
if (options.clockIfAllRead && newMessages.length==0)
643640
return load();

0 commit comments

Comments
 (0)