Skip to content

Commit

Permalink
fix: Crash on TokenTab when masterKey is cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldavidw committed Jun 19, 2024
1 parent e8fe81b commit 28fd891
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Chronos/App/Tabs/Tokens/TokensTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ let sortOptions: [(title: String, criteria: TokenSortOrder)] = [
struct TokensTab: View {
@Query private var vaults: [Vault]

@EnvironmentObject var loginStatus: LoginStatus

@State private var showTokenAddSheet = false
@State private var showTokenUpdateSheet = false
@State private var showTokenDeleteSheet = false
Expand All @@ -39,6 +41,11 @@ struct TokensTab: View {
let stateService = Container.shared.stateService()

private var tokenPairs: [TokenPair] {
// This is necessary because tokenPairs is a computed property. It gets recomputed whenever stateService changes, such as when stateService.masterKey gets cleared.
if !loginStatus.loggedIn {
return []
}

let vaultId = stateService.getVaultId()
guard let vault = vaults.filter({ $0.vaultId == vaultId }).first else {
return []
Expand Down

0 comments on commit 28fd891

Please sign in to comment.