Skip to content

Commit

Permalink
IOS-2478 Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mgolovko committed Apr 1, 2024
1 parent 4c9082b commit cb00cf7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class FeaturedRelationsBlockViewModel: BlockViewModelProtocol {
guard let self else { return }
if featuredRelationValues != newFeaturedRelations {
self.featuredRelationValues = newFeaturedRelations
collectionController.itemDidChangeFrame(item: .block(self))
collectionController.reconfigure(items: [.block(self)])
}
}.store(in: &cancellables)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ final class EditorPageController: UIViewController {
private let syncStatusData: SyncStatusData

private var cancellables = [AnyCancellable]()
private var applyAnimationConfig = false
private var dataSourceAnimationEnabled: Bool {
applyAnimationConfig ? EditorPageConfigurationConstants.dataSourceAnimationEnabled : false
}

// MARK: - Initializers
init(
Expand Down Expand Up @@ -327,7 +331,7 @@ extension EditorPageController: EditorPageViewInput {
func update(header: ObjectHeader) {
var headerSnapshot = NSDiffableDataSourceSectionSnapshot<EditorItem>()
headerSnapshot.append([.header(header)])
dataSource.apply(headerSnapshot, to: .header, animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled)
dataSource.apply(headerSnapshot, to: .header, animatingDifferences: false)

navigationBarHelper.configureNavigationBar(using: header)
}
Expand Down Expand Up @@ -358,22 +362,24 @@ extension EditorPageController: EditorPageViewInput {

let existingItems = items.filter { snapshot.itemIdentifiers.contains($0) }
snapshot.reconfigureItems(existingItems)
dataSource.apply(snapshot, animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled)
dataSource.apply(snapshot, animatingDifferences: true)
}

func update(
changes: CollectionDifference<EditorItem>?,
allModels: [EditorItem],
isRealData: Bool,
completion: @escaping () -> Void
) {
var blocksSnapshot = NSDiffableDataSourceSectionSnapshot<EditorItem>()
blocksSnapshot.append(allModels)

applyBlocksSectionSnapshot(
blocksSnapshot,
animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled,
animatingDifferences: dataSourceAnimationEnabled,
completion: completion
)
applyAnimationConfig = isRealData
}

func scrollToTopBlock(blockId: String) {
Expand Down Expand Up @@ -408,7 +414,7 @@ extension EditorPageController: EditorPageViewInput {
func itemDidChangeFrame(item: EditorItem) {
DispatchQueue.main.async { [weak self] in
guard let self else { return }
dataSource.apply(dataSource.snapshot(), animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled)
dataSource.apply(dataSource.snapshot(), animatingDifferences: true)
}
}

Expand Down Expand Up @@ -640,7 +646,7 @@ private extension EditorPageController {
dataSource.apply(
snapshot,
to: .main,
animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled,
animatingDifferences: animatingDifferences,
completion: completion
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protocol EditorPageViewInput: EditorCollectionReloadable {
func update(
changes: CollectionDifference<EditorItem>?,
allModels: [EditorItem],
isRealData: Bool,
completion: @escaping () -> Void
)
func update(syncStatus: SyncStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ final class EditorPageViewModel: EditorPageViewModelProtocol, EditorBottomNaviga
viewInput?.update(
changes: nil,
allModels: [shimmeringBlockViewModel],
isRealData: false,
completion: { }
)
}
Expand All @@ -135,7 +136,7 @@ final class EditorPageViewModel: EditorPageViewModelProtocol, EditorBottomNaviga

guard document.isOpened else { return }

viewInput?.update(changes: difference, allModels: modelsHolder.items) { [weak self] in
viewInput?.update(changes: difference, allModels: modelsHolder.items, isRealData: true) { [weak self] in
guard let self else { return }
cursorManager.handleGeneralUpdate(with: modelsHolder.items, type: document.details?.type)
}
Expand Down

0 comments on commit cb00cf7

Please sign in to comment.