Skip to content

Commit

Permalink
fix: update index, when using random()
Browse files Browse the repository at this point in the history
  • Loading branch information
KuramaSyu committed Jan 30, 2025
1 parent a706e24 commit 556f584
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils/impl/ImageIterator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ class StrategyBasedImageIterator: IteratorProtocol {
}

func random() -> NamedImage? {
return strategy.selectImage(from: items)
let image = strategy.selectImage(from: items)
guard let image = image else {return nil}
if let index = items.firstIndex(of: image) {
self.currentIndex = index
}
return image
}

func setStrategy(_ newStrategy: ImageSelectionStrategy) {
Expand Down

0 comments on commit 556f584

Please sign in to comment.