From 2cdd8af7c3e69ee748136aa86630a54b31e05da2 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sat, 17 Dec 2022 21:57:17 +0100 Subject: [PATCH] Remove workaround for tableviews --- Mastodon.xcodeproj/project.pbxproj | 4 --- .../UITableViewDiffableDataSource.swift | 25 ------------------- ...DiscoveryCommunityViewModel+Diffable.swift | 2 +- .../DiscoveryForYouViewModel+Diffable.swift | 2 +- .../DiscoveryNewsViewModel+Diffable.swift | 2 +- .../DiscoveryPostsViewModel+Diffable.swift | 2 +- .../Login/MastodonLoginViewController.swift | 2 +- ...astodonServerRulesViewModel+Diffable.swift | 2 +- .../Bookmark/BookmarkViewModel+Diffable.swift | 2 +- .../Favorite/FavoriteViewModel+Diffable.swift | 2 +- .../FollowedTags/FollowedTagsViewModel.swift | 2 +- .../UserTimelineViewModel+Diffable.swift | 2 +- .../ReportStatusViewModel+Diffable.swift | 2 +- 13 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 Mastodon/Extension/UITableViewDiffableDataSource.swift diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 08fdba14b..338e1e80a 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -307,7 +307,6 @@ DB72602725E36A6F00235243 /* MastodonServerRulesViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB72602625E36A6F00235243 /* MastodonServerRulesViewModel.swift */; }; DB7274F4273BB9B200577D95 /* ListBatchFetchViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB7274F3273BB9B200577D95 /* ListBatchFetchViewModel.swift */; }; DB73B490261F030A002E9E9F /* SafariActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB73B48F261F030A002E9E9F /* SafariActivity.swift */; }; - DB73BF4B27140C0800781945 /* UITableViewDiffableDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */; }; DB75BF1E263C1C1B00EDBF1F /* CustomScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB75BF1D263C1C1B00EDBF1F /* CustomScheduler.swift */; }; DB789A0B25F9F2950071ACA0 /* ComposeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB789A0A25F9F2950071ACA0 /* ComposeViewController.swift */; }; DB789A1225F9F2CC0071ACA0 /* ComposeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB789A1125F9F2CC0071ACA0 /* ComposeViewModel.swift */; }; @@ -880,7 +879,6 @@ DB72602625E36A6F00235243 /* MastodonServerRulesViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MastodonServerRulesViewModel.swift; sourceTree = ""; }; DB7274F3273BB9B200577D95 /* ListBatchFetchViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListBatchFetchViewModel.swift; sourceTree = ""; }; DB73B48F261F030A002E9E9F /* SafariActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariActivity.swift; sourceTree = ""; }; - DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITableViewDiffableDataSource.swift; sourceTree = ""; }; DB75BF1D263C1C1B00EDBF1F /* CustomScheduler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomScheduler.swift; sourceTree = ""; }; DB789A0A25F9F2950071ACA0 /* ComposeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewController.swift; sourceTree = ""; }; DB789A1125F9F2CC0071ACA0 /* ComposeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeViewModel.swift; sourceTree = ""; }; @@ -2283,7 +2281,6 @@ DB9E0D6E25EE008500CFDD76 /* UIInterpolatingMotionEffect.swift */, 2AE244472927831100BDBF7C /* UIImage+SFSymbols.swift */, DBCC3B2F261440A50045B23D /* UITabBarController.swift */, - DB73BF4A27140C0800781945 /* UITableViewDiffableDataSource.swift */, 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */, ); path = Extension; @@ -3406,7 +3403,6 @@ DB1E346825F518E20079D7DF /* CategoryPickerSection.swift in Sources */, DB7274F4273BB9B200577D95 /* ListBatchFetchViewModel.swift in Sources */, DB0618052785A73D0030EE79 /* RegisterItem.swift in Sources */, - DB73BF4B27140C0800781945 /* UITableViewDiffableDataSource.swift in Sources */, DBB525642612C988002F1F29 /* MeProfileViewModel.swift in Sources */, DB3EA8EF281B837000598866 /* DiscoveryCommunityViewController+DataSourceProvider.swift in Sources */, DB6B74EF272FB55000C70B6E /* FollowerListViewController.swift in Sources */, diff --git a/Mastodon/Extension/UITableViewDiffableDataSource.swift b/Mastodon/Extension/UITableViewDiffableDataSource.swift deleted file mode 100644 index 6e3968a14..000000000 --- a/Mastodon/Extension/UITableViewDiffableDataSource.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// UITableViewDiffableDataSource.swift -// Mastodon -// -// Created by Cirno MainasuK on 2021-10-11. -// - -import UIKit - -// ref: https://www.jessesquires.com/blog/2021/07/08/diffable-data-source-behavior-changes-and-reconfiguring-cells-in-ios-15/ -extension UITableViewDiffableDataSource { - func reloadData( - snapshot: NSDiffableDataSourceSnapshot, - completion: (() -> Void)? = nil - ) { - self.applySnapshotUsingReloadData(snapshot, completion: completion) - } - - func applySnapshot( - _ snapshot: NSDiffableDataSourceSnapshot, - animated: Bool, - completion: (() -> Void)? = nil) { - self.apply(snapshot, animatingDifferences: animated, completion: completion) - } -} diff --git a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel+Diffable.swift b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel+Diffable.swift index caa1f8460..a25dbaf1c 100644 --- a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel+Diffable.swift +++ b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewModel+Diffable.swift @@ -59,7 +59,7 @@ extension DiscoveryCommunityViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewModel+Diffable.swift b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewModel+Diffable.swift index af8d6ff47..31b14c55d 100644 --- a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewModel+Diffable.swift +++ b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewModel+Diffable.swift @@ -41,7 +41,7 @@ extension DiscoveryForYouViewModel { let items = records.map { DiscoveryItem.user($0) } snapshot.appendItems(items, toSection: .forYou) - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+Diffable.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+Diffable.swift index 11334dee8..deb8f48a7 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+Diffable.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewModel+Diffable.swift @@ -52,7 +52,7 @@ extension DiscoveryNewsViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+Diffable.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+Diffable.swift index f36812538..99d68796d 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+Diffable.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewModel+Diffable.swift @@ -59,7 +59,7 @@ extension DiscoveryPostsViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift index e9965fdde..9f9ce5d75 100644 --- a/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift +++ b/Mastodon/Scene/Onboarding/Login/MastodonLoginViewController.swift @@ -271,7 +271,7 @@ extension MastodonLoginViewController: MastodonLoginViewModelDelegate { snapshot.appendSections([MastodonLoginViewSection.servers]) snapshot.appendItems(viewModel.filteredServers) - dataSource?.applySnapshot(snapshot, animated: false) + dataSource?.apply(snapshot, animatingDifferences: false) OperationQueue.main.addOperation { let numberOfResults = viewModel.filteredServers.count diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel+Diffable.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel+Diffable.swift index f6385a529..ecb868eb0 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel+Diffable.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewModel+Diffable.swift @@ -21,6 +21,6 @@ extension MastodonServerRulesViewModel { return ServerRuleItem.rule(ruleContext) } snapshot.appendItems(ruleItems, toSection: .rules) - diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil) + diffableDataSource?.apply(snapshot, animatingDifferences: false) } } diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+Diffable.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+Diffable.swift index bb9148687..d52309e92 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewModel+Diffable.swift @@ -59,7 +59,7 @@ extension BookmarkViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+Diffable.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+Diffable.swift index e0f741f62..367a4d51f 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewModel+Diffable.swift @@ -59,7 +59,7 @@ extension FavoriteViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift index 75464092e..dbcf4d756 100644 --- a/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift +++ b/Mastodon/Scene/Profile/FollowedTags/FollowedTagsViewModel.swift @@ -47,7 +47,7 @@ final class FollowedTagsViewModel: NSObject { var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) snapshot.appendItems(records.map {.hashtag($0) }) - self.diffableDataSource?.applySnapshot(snapshot, animated: true) + self.diffableDataSource?.apply(snapshot, animatingDifferences: true) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift index 4992e653a..67f2b8035 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewModel+Diffable.swift @@ -83,7 +83,7 @@ extension UserTimelineViewModel { } } - diffableDataSource.applySnapshot(snapshot, animated: false) + diffableDataSource.apply(snapshot, animatingDifferences: false) } .store(in: &disposeBag) } diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift index 9879863d6..fce56a2b9 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewModel+Diffable.swift @@ -65,7 +65,7 @@ extension ReportStatusViewModel { break } - diffableDataSource.applySnapshot(snapshot, animated: false) { [weak self] in + diffableDataSource.apply(snapshot, animatingDifferences: false) { [weak self] in guard let self = self else { return } guard let diffableDataSource = self.diffableDataSource else { return }