File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
stocks@infinicode.de/components/stocks Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,9 @@ export const MenuStockTicker = GObject.registerClass({
310310 }
311311
312312 _showNextStock ( ) {
313- this . _visibleStockIndex = this . _visibleStockIndex + 1 >= this . _getEnabledSymbols ( ) . length ? 0 : this . _visibleStockIndex + 1
313+ const enabled = this . _getEnabledSymbols ( )
314+ const batchCount = Math . ceil ( enabled . length / this . _settings . ticker_stock_amount )
315+ this . _visibleStockIndex = ( this . _visibleStockIndex + 1 ) % Math . max ( batchCount , 1 )
314316 this . _sync ( ) . catch ( e => console . error ( e ) )
315317 }
316318
@@ -378,14 +380,17 @@ export const MenuStockTicker = GObject.registerClass({
378380 }
379381
380382 _getBatch ( items , index , amount ) {
381- const start = index * amount
382- const end = start + amount
383+ if ( isNullOrEmpty ( items ) ) {
384+ return [ ]
385+ }
383386
384- const batch = items . slice ( start , end )
387+ const batchCount = Math . ceil ( items . length / amount )
388+ const normalizedIndex = ( ( index % batchCount ) + batchCount ) % batchCount
389+ const start = normalizedIndex * amount
385390
386- if ( isNullOrEmpty ( batch ) ) {
387- this . _visibleStockIndex = 0
388- return items . slice ( 0 , amount )
391+ const batch = [ ]
392+ for ( let i = 0 ; i < amount ; i ++ ) {
393+ batch . push ( items [ ( start + i ) % items . length ] )
389394 }
390395
391396 return batch
You can’t perform that action at this time.
0 commit comments