@@ -48,6 +48,11 @@ to the clock. */
48
48
var unreadTimeout ;
49
49
/// List of all our messages
50
50
var MESSAGES = require ( "messages" ) . getMessages ( ) ;
51
+ if ( Bangle . MESSAGES ) {
52
+ // fast loading messages
53
+ Bangle . MESSAGES . forEach ( m => require ( "messages" ) . apply ( m , MESSAGES ) ) ;
54
+ delete Bangle . MESSAGES ;
55
+ }
51
56
52
57
var onMessagesModified = function ( type , msg ) {
53
58
if ( msg . handled ) return ;
@@ -105,7 +110,6 @@ function showMapMessage(msg) {
105
110
layout . render ( ) ;
106
111
function back ( ) { // mark as not new and return to menu
107
112
msg . new = false ;
108
- saveMessages ( ) ;
109
113
layout = undefined ;
110
114
checkMessages ( { clockIfNoMsg :1 , clockIfAllRead :1 , showMsgIfUnread :1 , openMusic :0 } ) ;
111
115
}
@@ -140,7 +144,6 @@ function showMusicMessage(msg) {
140
144
openMusic = false ;
141
145
var wasNew = msg . new ;
142
146
msg . new = false ;
143
- saveMessages ( ) ;
144
147
layout = undefined ;
145
148
if ( wasNew ) checkMessages ( { clockIfNoMsg :1 , clockIfAllRead :1 , showMsgIfUnread :0 , openMusic :0 } ) ;
146
149
else checkMessages ( { clockIfNoMsg :0 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :0 } ) ;
@@ -223,24 +226,20 @@ function showMessageSettings(msg) {
223
226
} ,
224
227
/*LANG*/ "Delete" : ( ) => {
225
228
MESSAGES = MESSAGES . filter ( m => m . id != msg . id ) ;
226
- saveMessages ( ) ;
227
229
checkMessages ( { clockIfNoMsg :0 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :0 } ) ;
228
230
} ,
229
231
/*LANG*/ "Mark Unread" : ( ) => {
230
232
msg . new = true ;
231
- saveMessages ( ) ;
232
233
checkMessages ( { clockIfNoMsg :0 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :0 } ) ;
233
234
} ,
234
235
/*LANG*/ "Mark all read" : ( ) => {
235
236
MESSAGES . forEach ( msg => msg . new = false ) ;
236
- saveMessages ( ) ;
237
237
checkMessages ( { clockIfNoMsg :0 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :0 } ) ;
238
238
} ,
239
239
/*LANG*/ "Delete all messages" : ( ) => {
240
240
E . showPrompt ( /*LANG*/ "Are you sure?" , { title :/*LANG*/ "Delete All Messages" } ) . then ( isYes => {
241
241
if ( isYes ) {
242
242
MESSAGES = [ ] ;
243
- saveMessages ( ) ;
244
243
}
245
244
checkMessages ( { clockIfNoMsg :0 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :0 } ) ;
246
245
} ) ;
@@ -295,15 +294,15 @@ function showMessage(msgid) {
295
294
}
296
295
function goBack ( ) {
297
296
layout = undefined ;
298
- msg . new = false ; saveMessages ( ) ; // read mail
297
+ msg . new = false ; // read mail
299
298
cancelReloadTimeout ( ) ; // don't auto-reload to clock now
300
299
checkMessages ( { clockIfNoMsg :1 , clockIfAllRead :0 , showMsgIfUnread :0 , openMusic :openMusic } ) ;
301
300
}
302
301
var buttons = [
303
302
] ;
304
303
if ( msg . positive ) {
305
304
buttons . push ( { type :"btn" , src :atob ( "GRSBAAAAAYAAAcAAAeAAAfAAAfAAAfAAAfAAAfAAAfBgAfA4AfAeAfAPgfAD4fAA+fAAP/AAD/AAA/AAAPAAADAAAA==" ) , cb :( ) => {
306
- msg . new = false ; saveMessages ( ) ;
305
+ msg . new = false ;
307
306
cancelReloadTimeout ( ) ; // don't auto-reload to clock now
308
307
Bangle . messageResponse ( msg , true ) ;
309
308
checkMessages ( { clockIfNoMsg :1 , clockIfAllRead :1 , showMsgIfUnread :1 , openMusic :openMusic } ) ;
@@ -312,7 +311,7 @@ function showMessage(msgid) {
312
311
if ( msg . negative ) {
313
312
if ( buttons . length ) buttons . push ( { width :32 } ) ; // nasty hack...
314
313
buttons . push ( { type :"btn" , src :atob ( "FhaBADAAMeAB78AP/4B/fwP4/h/B/P4D//AH/4AP/AAf4AB/gAP/AB/+AP/8B/P4P4fx/A/v4B//AD94AHjAAMA=" ) , cb :( ) => {
315
- msg . new = false ; saveMessages ( ) ;
314
+ msg . new = false ;
316
315
cancelReloadTimeout ( ) ; // don't auto-reload to clock now
317
316
Bangle . messageResponse ( msg , false ) ;
318
317
checkMessages ( { clockIfNoMsg :1 , clockIfAllRead :1 , showMsgIfUnread :1 , openMusic :openMusic } ) ;
0 commit comments