Fix current item index in wallpaper gallery

This commit is contained in:
Ali
2021-06-15 13:05:26 +04:00
parent bea2f13f24
commit c91f1e05b7
2 changed files with 16 additions and 11 deletions

View File

@@ -342,10 +342,10 @@ public class WallpaperGalleryController: ViewController {
return GalleryPagerTransaction(deleteItems: [], insertItems: [], updateItems: updateItems, focusOnItem: self.galleryNode.pager.centralItemNode()?.index, synchronous: false)
}
private func updateCurrentEntryTransaction(entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments) -> GalleryPagerTransaction {
private func updateCurrentEntryTransaction(entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments, index: Int) -> GalleryPagerTransaction {
var updateItems: [GalleryPagerUpdateItem] = []
for index in 0 ..< self.entries.count {
if index == self.centralEntryIndex {
for i in 0 ..< self.entries.count {
if i == index {
let item = GalleryPagerUpdateItem(index: index, previousIndex: index, item: WallpaperGalleryItem(context: self.context, index: index, entry: entry, arguments: arguments, source: self.source))
updateItems.append(item)
}
@@ -770,7 +770,7 @@ public class WallpaperGalleryController: ViewController {
entries[centralEntryIndex] = currentEntry
self.entries = entries
self.galleryNode.pager.transaction(self.updateCurrentEntryTransaction(entry: currentEntry, arguments: WallpaperGalleryItemArguments(colorPreview: preview, isColorsList: false, patternEnabled: self.patternPanelEnabled)))
self.galleryNode.pager.transaction(self.updateCurrentEntryTransaction(entry: currentEntry, arguments: WallpaperGalleryItemArguments(colorPreview: preview, isColorsList: false, patternEnabled: self.patternPanelEnabled), index: centralEntryIndex))
}
private func updateEntries(pattern: TelegramWallpaper?, intensity: Int32? = nil, preview: Bool = false) {