summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sora/Data/Booru/BooruManager.swift12
1 files changed, 5 insertions, 7 deletions
diff --git a/Sora/Data/Booru/BooruManager.swift b/Sora/Data/Booru/BooruManager.swift
index be78688..6f4bc1f 100644
--- a/Sora/Data/Booru/BooruManager.swift
+++ b/Sora/Data/Booru/BooruManager.swift
@@ -313,15 +313,13 @@ class BooruManager: ObservableObject { // swiftlint:disable:this type_body_leng
await MainActor.run {
withTransaction(Transaction(animation: nil)) {
- self.posts += chunk
+ let oldCount = self.posts.count
- let startIndex = self.posts.count
+ self.posts += chunk
- self.postIndexMap = Dictionary(
- uniqueKeysWithValues: chunk.enumerated().map { offset, post in
- (post.id, startIndex + offset)
- }
- )
+ for (offset, post) in chunk.enumerated() {
+ self.postIndexMap[post.id] = oldCount + offset
+ }
}
}
}