Skip to content

Commit

Permalink
Use factory for autofill prefs to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme committed Sep 19, 2024
1 parent d0b7ece commit 64e0d24
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions DuckDuckGo/DataImport/Model/DataImportViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ struct DataImportViewModel {

#endif

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

private let autofillPreferencesFactory: () -> AutofillPreferencesPersistor

init(importSource: Source? = nil,
screen: Screen? = nil,
Expand All @@ -147,6 +149,7 @@ struct DataImportViewModel {
requestPrimaryPasswordCallback: @escaping @MainActor (Source) -> String? = Self.requestPrimaryPasswordCallback,
openPanelCallback: @escaping @MainActor (DataType) -> URL? = Self.openPanelCallback,
reportSenderFactory: @escaping ReportSenderFactory = { FeedbackSender().sendDataImportReport },
autofillPreferencesFactory: @escaping () -> AutofillPreferencesPersistor = { AutofillPreferences() },
onFinished: @escaping () -> Void = {},
onCancelled: @escaping () -> Void = {}) {

Expand All @@ -161,6 +164,7 @@ struct DataImportViewModel {

self.browserProfiles = ThirdPartyBrowser.browser(for: importSource).map(loadProfiles)
self.selectedProfile = browserProfiles?.defaultProfile
self.autofillPreferencesFactory = autofillPreferencesFactory

self.selectedDataTypes = importSource.supportedDataTypes

Expand Down

0 comments on commit 64e0d24

Please sign in to comment.