Fix active profile not preselected on launch

Function called multiple times sets isFirstLaunch to true even if
not active profile.
This commit is contained in:
Davide De Rosa 2022-04-19 18:45:08 +02:00
parent 18e9f7cbb5
commit 923ea923ab
1 changed files with 10 additions and 11 deletions

View File

@ -101,7 +101,7 @@ extension OrganizerView {
ProfileHeaderRow(header: header) ProfileHeaderRow(header: header)
} }
}.onAppear { }.onAppear {
preselectActiveProfile(header.id) preselectIfActiveProfile(header.id)
} }
} }
} }
@ -134,23 +134,22 @@ extension OrganizerView.ProfilesList {
} }
extension OrganizerView.ProfilesList { extension OrganizerView.ProfilesList {
private func preselectActiveProfile(_ id: UUID) { private func preselectIfActiveProfile(_ id: UUID) {
guard isFirstLaunch else {
return
}
isFirstLaunch = false
// do not push profile if: // do not push profile if:
// //
// - an alert is active, as it would break navigation // - an alert is active, as it would break navigation
// - on iPad, as it's already shown // - on iPad, as it's already shown
// //
if alertType == nil, guard alertType == nil, themeIdiom != .pad, id == profileManager.activeHeader?.id else {
themeIdiom != .pad, return
id == profileManager.activeHeader?.id {
selectedProfileId = id
} }
guard isFirstLaunch else {
return
}
isFirstLaunch = false
selectedProfileId = id
} }
private func performMigrationsIfNeeded() { private func performMigrationsIfNeeded() {