From 091856ddf0fe908b4ad9f7abe1c79e0d8622c435 Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 22 Jun 2021 17:49:07 +0800 Subject: [PATCH] feat: add loader for initial snapshot and fix loader animation issue --- .../HomeTimeline/HomeTimelineViewModel+Diffable.swift | 10 +++++++--- .../Timeline/UserTimelineViewModel+Diffable.swift | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift index 6f5e66c0e..d83a8bfb8 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewModel+Diffable.swift @@ -33,9 +33,13 @@ extension HomeTimelineViewModel { threadReplyLoaderTableViewCellDelegate: nil ) -// var snapshot = NSDiffableDataSourceSnapshot() -// snapshot.appendSections([.main]) -// diffableDataSource?.apply(snapshot) + 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/Profile/Timeline/UserTimelineViewModel+Diffable.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift index 7e4ec8728..276c3566f 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift @@ -32,6 +32,9 @@ extension UserTimelineViewModel { // set empty section to make update animation top-to-bottom style var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) + diffableDataSource?.apply(snapshot) + + // workaround to append loader wrong animation issue snapshot.appendItems([.bottomLoader], toSection: .main) diffableDataSource?.apply(snapshot) }