Skip to content

Commit

Permalink
Lazy load the autolock var
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme committed Sep 19, 2024
1 parent e075a37 commit cb88fc3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DuckDuckGo/DataImport/Model/DataImportViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ struct DataImportViewModel {

#endif

let isPasswordManagerAutolockEnabled: Bool
lazy var isPasswordManagerAutolockEnabled: Bool = {
AutofillPreferences().isAutoLockEnabled
}()

init(importSource: Source? = nil,
screen: Screen? = nil,
availableImportSources: [DataImport.Source] = Source.allCases.filter { $0.canImportData },
preferredImportSources: [Source] = [.chrome, .firefox, .safari],
summary: [DataTypeImportResult] = [],
isPasswordManagerAutolockEnabled: Bool = AutofillPreferences().isAutoLockEnabled,
loadProfiles: @escaping (ThirdPartyBrowser) -> BrowserProfileList = { $0.browserProfiles() },
dataImporterFactory: @escaping DataImporterFactory = dataImporter,
requestPrimaryPasswordCallback: @escaping @MainActor (Source) -> String? = Self.requestPrimaryPasswordCallback,
Expand All @@ -164,7 +165,6 @@ struct DataImportViewModel {
self.selectedDataTypes = importSource.supportedDataTypes

self.summary = summary
self.isPasswordManagerAutolockEnabled = isPasswordManagerAutolockEnabled

self.requestPrimaryPasswordCallback = requestPrimaryPasswordCallback
self.openPanelCallback = openPanelCallback
Expand Down Expand Up @@ -687,7 +687,7 @@ extension DataImportViewModel {
}

mutating func update(with importSource: Source) {
self = .init(importSource: importSource, isPasswordManagerAutolockEnabled: isPasswordManagerAutolockEnabled, loadProfiles: loadProfiles, dataImporterFactory: dataImporterFactory, requestPrimaryPasswordCallback: requestPrimaryPasswordCallback, reportSenderFactory: reportSenderFactory, onFinished: onFinished, onCancelled: onCancelled)
self = .init(importSource: importSource, loadProfiles: loadProfiles, dataImporterFactory: dataImporterFactory, requestPrimaryPasswordCallback: requestPrimaryPasswordCallback, reportSenderFactory: reportSenderFactory, onFinished: onFinished, onCancelled: onCancelled)
}

@MainActor
Expand Down

0 comments on commit cb88fc3

Please sign in to comment.