From 6400729367b2f005b14089acb85dac1281cf55c5 Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 22 Jun 2021 17:58:11 +0800 Subject: [PATCH] feat: add loader for initial snapshot in notification scene --- .../Notification/NotificationViewModel+diffable.swift | 8 ++++++++ Mastodon/Scene/Notification/NotificationViewModel.swift | 1 + 2 files changed, 9 insertions(+) diff --git a/Mastodon/Scene/Notification/NotificationViewModel+diffable.swift b/Mastodon/Scene/Notification/NotificationViewModel+diffable.swift index 4e0d9b6d..7ef313e1 100644 --- a/Mastodon/Scene/Notification/NotificationViewModel+diffable.swift +++ b/Mastodon/Scene/Notification/NotificationViewModel+diffable.swift @@ -29,6 +29,14 @@ extension NotificationViewModel { delegate: delegate, dependency: dependency ) + + var snapshot = NSDiffableDataSourceSnapshot() + snapshot.appendSections([.main]) + diffableDataSource.apply(snapshot) + + // workaround to append loader wrong animation issue + snapshot.appendItems([.bottomLoader], toSection: .main) + diffableDataSource.apply(snapshot) } } diff --git a/Mastodon/Scene/Notification/NotificationViewModel.swift b/Mastodon/Scene/Notification/NotificationViewModel.swift index f535c559..8ecec790 100644 --- a/Mastodon/Scene/Notification/NotificationViewModel.swift +++ b/Mastodon/Scene/Notification/NotificationViewModel.swift @@ -35,6 +35,7 @@ final class NotificationViewModel: NSObject { // output var diffableDataSource: UITableViewDiffableDataSource! + // top loader private(set) lazy var loadLatestStateMachine: GKStateMachine = { // exclude timeline middle fetcher state