Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldavidw committed Jun 14, 2024
1 parent 53d4e1e commit 26311f2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Chronos/Services/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Container {
var vaultService: Factory<VaultService> {
Factory(self) { VaultService() }
}

var cryptoService: Factory<CryptoService> {
Factory(self) { CryptoService() }
}
Expand Down
4 changes: 2 additions & 2 deletions Chronos/Services/CryptoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class CryptoService {
}
}

func unwrapMasterKeyWithUserPassword(password: [UInt8], isRestore: Bool = false) async -> Bool {
func unwrapMasterKeyWithUserPassword(password: [UInt8], isRestore _: Bool = false) async -> Bool {
guard let vault = vaultService.getFirstVault() else {
return false
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public class CryptoService {
if decrypt.success {
stateService.masterKey = SecureBytes(bytes: decrypt.plainText)
stateService.setVaultId(vaultId: vault.vaultId!)

decrypt.plainText.removeAll()
return true
} else {
Expand Down
8 changes: 4 additions & 4 deletions Chronos/Services/StateService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ public class StateService {

var masterKey: SecureBytes = .init(bytes: [])
var vault: Vault?

func setVaultId(vaultId: UUID) {
defaults.setValue(vaultId.uuidString, forKey: StateEnum.VAULT_ID.rawValue)
}

func getVaultId() -> UUID? {
guard let vaultIdStr = defaults.string(forKey: StateEnum.VAULT_ID.rawValue) else {
return nil
}

return UUID(uuidString: vaultIdStr)
}

func resetAllStates() {
defaults.setValue(false, forKey: StateEnum.VAULT_ID.rawValue)
defaults.setValue(false, forKey: StateEnum.ICLOUD_BACKUP_ENABLED.rawValue)
Expand Down
14 changes: 7 additions & 7 deletions Chronos/Services/VaultService.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Factory
import Foundation
import SwiftData
import Logging
import SwiftData

public class VaultService {
private let logger = Logger(label: "VaultService")

private let stateService = Container.shared.stateService()
private let swiftDataService = Container.shared.swiftDataService()

// TODO(joeldavidw): Selects first vault for now. Selection page should be shown if there are more than one vault.
func getFirstVault() -> Vault? {
let context = ModelContext(swiftDataService.getCloudModelContainer())
Expand All @@ -17,17 +17,17 @@ public class VaultService {
logger.error("No vaults found")
return nil
}

guard let vault = vaultArr.first else {
logger.error("Empty vaultArr")
return nil
}

stateService.setVaultId(vaultId: vault.vaultId!)

return vault
}

func getVault() -> Vault? {
guard let vaultId: UUID = stateService.getVaultId() else {
logger.error("vaultId not found in AppStorage")
Expand All @@ -42,7 +42,7 @@ public class VaultService {
logger.error("No vaults found")
return nil
}

return vaultArr.first
}
}

0 comments on commit 26311f2

Please sign in to comment.