@@ -278,9 +278,9 @@ function showMessageScroller2(msg, initAtEndOfMsg, persist, alreadyProcessed) {
278278 if ( initAtEndOfMsg === undefined ) { initAtEndOfMsg = false ; }
279279 if ( persist === undefined ) { persist = true ; }
280280 if ( ! ! alreadyProcessed ) {
281- alreadyProcessed = { } ;
282- alreadyProcessed . lines = [ ] ;
283- alreadyProcessed . idxSpan = [ ] ;
281+ alreadyProcessed = { lines : [ ] , idxSpan : [ ] } ;
282+ // alreadyProcessed.lines = [];
283+ // alreadyProcessed.idxSpan = [];
284284 }
285285
286286 if ( replying ) { return ; }
@@ -292,18 +292,18 @@ function showMessageScroller2(msg, initAtEndOfMsg, persist, alreadyProcessed) {
292292
293293 let msgIdx = MESSAGES . findIndex ( ( m ) => m . id == msg . id )
294294 //print("msgIdx",msgIdx);
295- let startIdx ;
296- let stopIdx ;
295+ let startIdx = 0 ;
296+ let stopIdx = 0 ;
297297
298298 if ( alreadyProcessed . idxSpan . length === 0 ) {
299299 startIdx = Math . max ( msgIdx - 1 , 0 ) ;
300300 stopIdx = Math . min ( msgIdx + 2 , MESSAGES . length ) ;
301- } else if ( msgIdx > alreadyProcessed . idxSpan [ 0 ] && msgid < alreadyProcessed . idxSpan [ 1 ] ) {
302- startIdx = msgIdx ;
303- stopIdx = msgIdx + 1 ;
304- } else {
305- startIdx = msgIdx ;
306- stopIdx = msgIdx ;
301+ } else if ( msgIdx < alreadyProcessed . startIdx ) {
302+ startIdx = Math . max ( msgIdx , 0 ) ;
303+ stopIdx = alreadyProcessed . startIdx ;
304+ } else if ( msgid >= alreadyProcessed . stopIdx ) {
305+ startIdx = alreadyProcessed . stopIdx ;
306+ stopIdx = Math . min ( msgIdx , MESSAGES . length ) ;
307307 }
308308
309309 active = "scroller" ;
@@ -359,6 +359,14 @@ function showMessageScroller2(msg, initAtEndOfMsg, persist, alreadyProcessed) {
359359 //print("allLines2:\n",allLines2);
360360 //print("messagesWrapped:\n",messagesWrapped);
361361
362+ let cacheObj = {
363+ lines : allLines2 ,
364+ startIdx : Math . min ( startIdx , alreadyProcessed . startIdx ) ,
365+ stopIdx : Math . max ( stopIdx , alreadyProcessed . stopIdx ) ,
366+ titleLines : titleLines ,
367+ messagesWrappedLength : messagesWrapped . length ,
368+ } ;
369+
362370 E . showScroller ( {
363371 scroll : initScroll * g . getFontHeight ( ) ,
364372 h : g . getFontHeight ( ) , // height of each menu item in pixels
@@ -373,12 +381,12 @@ function showMessageScroller2(msg, initAtEndOfMsg, persist, alreadyProcessed) {
373381 g . setFont ( bodyFont ) . setFontAlign ( 0 , - 1 ) . drawString ( allLines2 [ idx ] , r . x + r . w / 2 , r . y ) ;
374382 if ( idx >= allLines2 . length - 1 && msgIdx < MESSAGES . length - 1 ) {
375383 setTimeout ( ( ) => {
376- showMessageScroller2 ( MESSAGES [ msgIdx + 1 ] , true ) ;
384+ showMessageScroller2 ( MESSAGES [ msgIdx + 1 ] , true , cacheObj ) ;
377385 } , 0 )
378386 }
379387 if ( idx == 0 && msgIdx > 0 ) {
380388 setTimeout ( ( ) => {
381- showMessageScroller2 ( MESSAGES [ msgIdx - 1 ] , false ) ;
389+ showMessageScroller2 ( MESSAGES [ msgIdx - 1 ] , false , cacheObj ) ;
382390 } , 0 )
383391 }
384392 } , select : function ( idx , touch ) {
0 commit comments