From c9417a2e172b19ba9e2d7a44757ac5a8da13e998 Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 4 Jan 2022 18:44:42 +0800 Subject: [PATCH] fix: category initial selection missing issue --- .../PickServer/MastodonPickServerViewController.swift | 1 - .../PickServer/MastodonPickServerViewModel+Diffable.swift | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift index 1fbf204f1..54e7bc6de 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewController.swift @@ -110,7 +110,6 @@ extension MastodonPickServerViewController { .observe(\.bounds, options: [.initial, .new]) { [weak self] navigationActionView, _ in guard let self = self else { return } let inset = navigationActionView.frame.height - print("*** \(inset) ***") self.tableView.contentInset.bottom = inset } .store(in: &observations) diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+Diffable.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+Diffable.swift index 152786722..35de40b8f 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+Diffable.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel+Diffable.swift @@ -25,7 +25,11 @@ extension MastodonPickServerViewModel { sectionHeaderSnapshot.appendSections([.main]) sectionHeaderSnapshot.appendItems(categoryPickerItems, toSection: .main) serverSectionHeaderView.delegate = pickServerServerSectionTableHeaderViewDelegate - serverSectionHeaderView.diffableDataSource?.applySnapshot(sectionHeaderSnapshot, animated: false) + serverSectionHeaderView.diffableDataSource?.applySnapshot(sectionHeaderSnapshot, animated: false) { [weak self] in + guard let self = self else { return } + guard let indexPath = self.serverSectionHeaderView.diffableDataSource?.indexPath(for: .all) else { return } + self.serverSectionHeaderView.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally) + } // set tableView diffableDataSource = PickServerSection.tableViewDiffableDataSource(