Skip to content

Commit b9b15c6

Browse files
authored
[PM-6498] Fix vault autofill showing/hiding website icons. (#789)
1 parent c205ed8 commit b9b15c6

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListEffect.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ enum VaultAutofillListEffect: Equatable {
2222

2323
/// Stream the autofill items for the user.
2424
case streamAutofillItems
25+
26+
/// Stream the show web icons setting.
27+
case streamShowWebIcons
2528
}

BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListProcessor.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class VaultAutofillListProcessor: StateProcessor<
2020
& HasFido2CredentialStore
2121
& HasFido2UserInterfaceHelper
2222
& HasPasteboardService
23+
& HasStateService
2324
& HasTimeProvider
2425
& HasVaultRepository
2526

@@ -110,6 +111,10 @@ class VaultAutofillListProcessor: StateProcessor<
110111
await searchVault(for: text)
111112
case .streamAutofillItems:
112113
await streamAutofillItems()
114+
case .streamShowWebIcons:
115+
for await value in await services.stateService.showWebIconsPublisher().values {
116+
state.showWebIcons = value
117+
}
113118
}
114119
}
115120

BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListProcessorTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class VaultAutofillListProcessorTests: BitwardenTestCase { // swiftlint:disable:
1313
var errorReporter: MockErrorReporter!
1414
var fido2CredentialStore: MockFido2CredentialStore!
1515
var fido2UserInterfaceHelper: MockFido2UserInterfaceHelper!
16+
var stateService: MockStateService!
1617
var subject: VaultAutofillListProcessor!
1718
var vaultRepository: MockVaultRepository!
1819

@@ -28,6 +29,7 @@ class VaultAutofillListProcessorTests: BitwardenTestCase { // swiftlint:disable:
2829
errorReporter = MockErrorReporter()
2930
fido2CredentialStore = MockFido2CredentialStore()
3031
fido2UserInterfaceHelper = MockFido2UserInterfaceHelper()
32+
stateService = MockStateService()
3133
vaultRepository = MockVaultRepository()
3234

3335
subject = VaultAutofillListProcessor(
@@ -39,6 +41,7 @@ class VaultAutofillListProcessorTests: BitwardenTestCase { // swiftlint:disable:
3941
errorReporter: errorReporter,
4042
fido2CredentialStore: fido2CredentialStore,
4143
fido2UserInterfaceHelper: fido2UserInterfaceHelper,
44+
stateService: stateService,
4245
vaultRepository: vaultRepository
4346
),
4447
state: VaultAutofillListState()
@@ -55,6 +58,7 @@ class VaultAutofillListProcessorTests: BitwardenTestCase { // swiftlint:disable:
5558
errorReporter = nil
5659
fido2CredentialStore = nil
5760
fido2UserInterfaceHelper = nil
61+
stateService = nil
5862
subject = nil
5963
vaultRepository = nil
6064
}
@@ -247,6 +251,19 @@ class VaultAutofillListProcessorTests: BitwardenTestCase { // swiftlint:disable:
247251
XCTAssertEqual(errorReporter.errors.last as? BitwardenTestError, .example)
248252
}
249253

254+
/// `perform(_:)` with `.streamShowWebIcons` requests the value of the show
255+
/// web icons parameter from the state service.
256+
func test_perform_streamShowWebIcons() {
257+
let task = Task {
258+
await subject.perform(.streamShowWebIcons)
259+
}
260+
261+
stateService.showWebIconsSubject.send(false)
262+
waitFor(subject.state.showWebIcons == false)
263+
264+
task.cancel()
265+
}
266+
250267
/// `receive(_:)` with `.addTapped` navigates to the add item view.
251268
func test_receive_addTapped() {
252269
subject.receive(.addTapped(fromToolbar: false))

BitwardenShared/UI/Vault/Vault/AutofillList/VaultAutofillListView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ private struct VaultAutofillListSearchableView: View {
9494
.task {
9595
await store.perform(.streamAutofillItems)
9696
}
97+
.task {
98+
await store.perform(.streamShowWebIcons)
99+
}
97100
.task(id: store.state.searchText) {
98101
await store.perform(.search(store.state.searchText))
99102
}

0 commit comments

Comments
 (0)