forked from zelo72/mastodon-ios
fix: wizard display before sign-in at the first time install issue
This commit is contained in:
parent
868e86e077
commit
29e3d10e97
|
@ -252,6 +252,14 @@ extension MainTabBarController {
|
||||||
tabBarLongPressGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarLongPressGestureRecognizerHandler(_:)))
|
tabBarLongPressGestureRecognizer.addTarget(self, action: #selector(MainTabBarController.tabBarLongPressGestureRecognizerHandler(_:)))
|
||||||
tabBar.addGestureRecognizer(tabBarLongPressGestureRecognizer)
|
tabBar.addGestureRecognizer(tabBarLongPressGestureRecognizer)
|
||||||
|
|
||||||
|
context.authenticationService.activeMastodonAuthenticationBox
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak self] authenticationBox in
|
||||||
|
guard let self = self else { return }
|
||||||
|
self.isReadyForWizardAvatarButton = authenticationBox != nil
|
||||||
|
}
|
||||||
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
currentTab
|
currentTab
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak self] tab in
|
.sink { [weak self] tab in
|
||||||
|
@ -267,12 +275,6 @@ extension MainTabBarController {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
|
||||||
super.viewDidAppear(animated)
|
|
||||||
|
|
||||||
isReadyForWizardAvatarButton = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
||||||
|
|
|
@ -18,32 +18,36 @@ final class SidebarViewModel {
|
||||||
|
|
||||||
// input
|
// input
|
||||||
let context: AppContext
|
let context: AppContext
|
||||||
let searchHistoryFetchedResultController: SearchHistoryFetchedResultController
|
@Published private var isSidebarDataSourceReady = false
|
||||||
|
@Published private var isAvatarButtonDataReady = false
|
||||||
|
|
||||||
// output
|
// output
|
||||||
var diffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
var diffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
||||||
var secondaryDiffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
var secondaryDiffableDataSource: UICollectionViewDiffableDataSource<Section, Item>?
|
||||||
private(set) var isReadyForWizardAvatarButton = false
|
@Published private(set) var isReadyForWizardAvatarButton = false
|
||||||
|
|
||||||
let activeMastodonAuthenticationObjectID = CurrentValueSubject<NSManagedObjectID?, Never>(nil)
|
let activeMastodonAuthenticationObjectID = CurrentValueSubject<NSManagedObjectID?, Never>(nil)
|
||||||
|
|
||||||
init(context: AppContext) {
|
init(context: AppContext) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.searchHistoryFetchedResultController = SearchHistoryFetchedResultController(managedObjectContext: context.managedObjectContext)
|
|
||||||
|
Publishers.CombineLatest(
|
||||||
|
$isSidebarDataSourceReady,
|
||||||
|
$isAvatarButtonDataReady
|
||||||
|
)
|
||||||
|
.map { $0 && $1 }
|
||||||
|
.assign(to: &$isReadyForWizardAvatarButton)
|
||||||
|
|
||||||
context.authenticationService.activeMastodonAuthentication
|
context.authenticationService.activeMastodonAuthentication
|
||||||
.sink { [weak self] authentication in
|
.sink { [weak self] authentication in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
// bind search history
|
|
||||||
self.searchHistoryFetchedResultController.domain.value = authentication?.domain
|
|
||||||
self.searchHistoryFetchedResultController.userID.value = authentication?.userID
|
|
||||||
|
|
||||||
// bind objectID
|
// bind objectID
|
||||||
self.activeMastodonAuthenticationObjectID.value = authentication?.objectID
|
self.activeMastodonAuthenticationObjectID.value = authentication?.objectID
|
||||||
|
|
||||||
|
self.isAvatarButtonDataReady = authentication != nil
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
try? searchHistoryFetchedResultController.fetchedResultsController.performFetch()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -175,7 +179,7 @@ extension SidebarViewModel {
|
||||||
// otherwise the UI layout will infinity loop
|
// otherwise the UI layout will infinity loop
|
||||||
_diffableDataSource.apply(sectionSnapshot, to: .main, animatingDifferences: true) { [weak self] in
|
_diffableDataSource.apply(sectionSnapshot, to: .main, animatingDifferences: true) { [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.isReadyForWizardAvatarButton = true
|
self.isSidebarDataSourceReady = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// secondary
|
// secondary
|
||||||
|
|
Loading…
Reference in New Issue