diff --git a/Anytype/Sources/PresentationLayer/TextEditor/BlocksViews/Blocks/FeaturedRelations/FeaturedRelationsBlockViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/BlocksViews/Blocks/FeaturedRelations/FeaturedRelationsBlockViewModel.swift index 53b2f51398..ff6019f8a7 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/BlocksViews/Blocks/FeaturedRelations/FeaturedRelationsBlockViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/BlocksViews/Blocks/FeaturedRelations/FeaturedRelationsBlockViewModel.swift @@ -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) } diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageController.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageController.swift index 042f164df2..5775a912e6 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageController.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageController.swift @@ -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( @@ -327,7 +331,7 @@ extension EditorPageController: EditorPageViewInput { func update(header: ObjectHeader) { var headerSnapshot = NSDiffableDataSourceSectionSnapshot() headerSnapshot.append([.header(header)]) - dataSource.apply(headerSnapshot, to: .header, animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled) + dataSource.apply(headerSnapshot, to: .header, animatingDifferences: false) navigationBarHelper.configureNavigationBar(using: header) } @@ -358,12 +362,13 @@ 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?, allModels: [EditorItem], + isRealData: Bool, completion: @escaping () -> Void ) { var blocksSnapshot = NSDiffableDataSourceSectionSnapshot() @@ -371,9 +376,10 @@ extension EditorPageController: EditorPageViewInput { applyBlocksSectionSnapshot( blocksSnapshot, - animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled, + animatingDifferences: dataSourceAnimationEnabled, completion: completion ) + applyAnimationConfig = isRealData } func scrollToTopBlock(blockId: String) { @@ -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) } } @@ -640,7 +646,7 @@ private extension EditorPageController { dataSource.apply( snapshot, to: .main, - animatingDifferences: EditorPageConfigurationConstants.dataSourceAnimationEnabled, + animatingDifferences: animatingDifferences, completion: completion ) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewInput.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewInput.swift index dd343b39ab..8a6c1d1371 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewInput.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewInput.swift @@ -22,6 +22,7 @@ protocol EditorPageViewInput: EditorCollectionReloadable { func update( changes: CollectionDifference?, allModels: [EditorItem], + isRealData: Bool, completion: @escaping () -> Void ) func update(syncStatus: SyncStatus) diff --git a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModel.swift b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModel.swift index 0634d89fd5..9c5b16d2e2 100644 --- a/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModel.swift +++ b/Anytype/Sources/PresentationLayer/TextEditor/EditorPage/EditorPageViewModel.swift @@ -119,6 +119,7 @@ final class EditorPageViewModel: EditorPageViewModelProtocol, EditorBottomNaviga viewInput?.update( changes: nil, allModels: [shimmeringBlockViewModel], + isRealData: false, completion: { } ) } @@ -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) }