@@ -302,7 +302,6 @@ function showMessagesScroller(msg, persist) {
302
302
for ( let i = 0 ; i < MESSAGES . length ; i ++ ) {
303
303
if ( MSG_IDX === i ) { initScroll = allLines . length * FONT_HEIGHT }
304
304
let msgIter = MESSAGES [ i ] ;
305
- msgIter . new = false ; // FIXME: Update "new" status in the scrollers draw method instead. A message should not be marked as read if it has not been displayed on screen.
306
305
307
306
var lines = [ ] ;
308
307
const TITLE_STRING = msgIter . title || msgIter . sender || msgIter . subject || msgIter . src || /*LANG*/ "No Title" ;
@@ -321,32 +320,42 @@ function showMessagesScroller(msg, persist) {
321
320
returnToClockIfEmpty ( ) ;
322
321
}
323
322
323
+ let shownIdxFirst = allLines . length
324
+ let shownIdxLast = 0 ;
325
+
324
326
E . showScroller ( {
325
327
scroll : initScroll ,
326
328
h : FONT_HEIGHT , // height of each menu item in pixels
327
329
c : allLines . length , // number of menu items
328
330
// a function to draw a menu item
329
331
draw : function ( scrollIdx , r ) { "ram" ;
332
+ //print(scrollIdx)
330
333
g . setBgColor ( titleLines . find ( e => e == scrollIdx ) !== undefined ? g . theme . bg2 : g . theme . bg ) .
331
334
setColor ( titleLines . find ( e => e == scrollIdx ) !== undefined ? g . theme . fg2 : g . theme . fg ) .
332
335
clearRect ( r ) ;
333
336
g . setFont ( bodyFont ) . setFontAlign ( 0 , - 1 ) . drawString ( allLines [ scrollIdx ] , r . x + r . w / 2 , r . y ) ;
337
+ if ( scrollIdx < shownIdxFirst ) { shownIdxFirst = scrollIdx ; }
338
+ if ( scrollIdx > shownIdxLast ) { shownIdxLast = scrollIdx ; }
334
339
if ( ! persist ) { resetReloadTimeout ( ) ; }
335
340
} ,
336
341
select : function ( scrollIdx , touch ) {
337
342
WU . show ( ) ;
338
- clearBtnHandler ( ) ;
339
343
for ( let i = firstTitleLinePerMsg . length - 1 ; i >= 0 ; i -- ) {
340
344
if ( scrollIdx >= firstTitleLinePerMsg [ i ] ) {
341
- if ( ! touch || touch . type === 0 ) { showMessageRouter ( MESSAGES [ i ] , true ,
342
- "overview" ) ; return ; }
343
- if ( touch . type == 2 ) { showMessageSettings ( MESSAGES [ i ] ) ; }
345
+ if ( ! touch || touch . type === 0 ) {
346
+ showMessageRouter ( MESSAGES [ i ] , true , "overview" )
347
+ } else if ( touch . type == 2 ) {
348
+ showMessageSettings ( MESSAGES [ i ] ) ;
349
+ }
344
350
break ;
345
351
}
346
352
}
353
+ clearBtnHandler ( ) ;
354
+ updateReadMessages ( ) ;
347
355
}
348
356
} ) ;
349
357
358
+
350
359
// If Bangle.js 2 add an external select hw button handler.
351
360
let btnHandler = ( ( 2 === process . env . HWVERSION ) && ( setWatch ( ( ) => {
352
361
Bangle . emit ( "drag" , { dy :0 } ) ; // Compatibility with `kineticscroll`, stopping the scroller so it doesn't continue scrolling when the `showMessageOverview` screen is loaded.
@@ -360,6 +369,35 @@ function showMessagesScroller(msg, persist) {
360
369
function clearBtnHandler ( ) {
361
370
if ( btnHandler ) { clearWatch ( btnHandler ) ; btnHandler = undefined ; }
362
371
}
372
+
373
+ function updateReadMessages ( ) {
374
+ let shownMsgIdxFirst , shownMsgIdxLast ;
375
+ const LINES_PER_SCREEN = APP_RECT . h / FONT_HEIGHT ;
376
+ //print(firstTitleLinePerMsg)
377
+ //print(shownIdxFirst, shownIdxLast)
378
+
379
+ for ( let i = 0 ; i < firstTitleLinePerMsg . length - 1 ; i ++ ) {
380
+
381
+ if ( shownIdxFirst <= firstTitleLinePerMsg [ i ] && shownIdxFirst + LINES_PER_SCREEN > firstTitleLinePerMsg [ i ] ) {
382
+ shownMsgIdxFirst = i ;
383
+ }
384
+
385
+ if ( shownIdxLast >= firstTitleLinePerMsg [ i + 1 ] && shownIdxLast - LINES_PER_SCREEN < firstTitleLinePerMsg [ i + 1 ] ) {
386
+ shownMsgIdxLast = i ;
387
+ //print(i)
388
+ }
389
+
390
+ }
391
+ if ( shownIdxLast === allLines . length - 1 ) { shownMsgIdxLast = MESSAGES . length - 1 ; }
392
+
393
+ //print(shownIdxFirst, shownIdxLast)
394
+ //print(shownMsgIdxFirst, shownMsgIdxLast)
395
+ //print(MESSAGES)
396
+ for ( let i = shownMsgIdxFirst ; i < shownMsgIdxLast + 1 ; i ++ ) {
397
+ MESSAGES [ i ] . new = false ;
398
+ }
399
+ //print(MESSAGES)
400
+ }
363
401
}
364
402
365
403
function showMessageSettings ( msg ) {
0 commit comments