From 26311f2ab49e54cf2fa22b7dea2c7c5a16deab34 Mon Sep 17 00:00:00 2001 From: Joel-David Date: Fri, 14 Jun 2024 22:22:32 +0800 Subject: [PATCH] lint --- Chronos/Services/Container.swift | 2 +- Chronos/Services/CryptoService.swift | 4 ++-- Chronos/Services/StateService.swift | 8 ++++---- Chronos/Services/VaultService.swift | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Chronos/Services/Container.swift b/Chronos/Services/Container.swift index bb6eb3d..759350a 100644 --- a/Chronos/Services/Container.swift +++ b/Chronos/Services/Container.swift @@ -13,7 +13,7 @@ extension Container { var vaultService: Factory { Factory(self) { VaultService() } } - + var cryptoService: Factory { Factory(self) { CryptoService() } } diff --git a/Chronos/Services/CryptoService.swift b/Chronos/Services/CryptoService.swift index df9a24b..17c093c 100644 --- a/Chronos/Services/CryptoService.swift +++ b/Chronos/Services/CryptoService.swift @@ -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 } @@ -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 { diff --git a/Chronos/Services/StateService.swift b/Chronos/Services/StateService.swift index 3b537be..a6eacfb 100644 --- a/Chronos/Services/StateService.swift +++ b/Chronos/Services/StateService.swift @@ -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) diff --git a/Chronos/Services/VaultService.swift b/Chronos/Services/VaultService.swift index 2075d56..3097527 100644 --- a/Chronos/Services/VaultService.swift +++ b/Chronos/Services/VaultService.swift @@ -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()) @@ -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") @@ -42,7 +42,7 @@ public class VaultService { logger.error("No vaults found") return nil } - + return vaultArr.first } }