Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIT-2284: Display unassigned ciphers banner #638

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BitwardenShared/Core/Platform/Services/ConfigService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ extension ConfigService {
await getConfig(forceRefresh: false)
}

func getFeatureFlag(_ flag: FeatureFlag, defaultValue: Bool) async -> Bool {
func getFeatureFlag(_ flag: FeatureFlag, defaultValue: Bool = false) async -> Bool {
await getFeatureFlag(flag, defaultValue: defaultValue, forceRefresh: false)
}

func getFeatureFlag(_ flag: FeatureFlag, defaultValue: Int) async -> Int {
func getFeatureFlag(_ flag: FeatureFlag, defaultValue: Int = 0) async -> Int {
await getFeatureFlag(flag, defaultValue: defaultValue, forceRefresh: false)
}

func getFeatureFlag(_ flag: FeatureFlag, defaultValue: String?) async -> String? {
func getFeatureFlag(_ flag: FeatureFlag, defaultValue: String? = nil) async -> String? {
await getFeatureFlag(flag, defaultValue: defaultValue, forceRefresh: false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ final class VaultListProcessor: StateProcessor<
/// The services used by this processor.
private let services: Services

private var isShowingNotificationPermissions = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โ›๏ธ Could you add docs for this?


// MARK: Initialization

/// Creates a new `VaultListProcessor`.
Expand Down Expand Up @@ -59,7 +61,9 @@ final class VaultListProcessor: StateProcessor<
await requestNotificationPermissions()
await checkPendingLoginRequests()
await checkPersonalOwnershipPolicy()
await checkUnassignedCiphers()
if !isShowingNotificationPermissions {
await checkUnassignedCiphers()
}
case let .morePressed(item):
await showMoreOptionsAlert(for: item)
case let .profileSwitcher(profileEffect):
Expand Down Expand Up @@ -219,6 +223,8 @@ extension VaultListProcessor {
let notificationAuthorization = await services.notificationService.notificationAuthorization()
guard notificationAuthorization == .notDetermined else { return }

isShowingNotificationPermissions = true

// Show the explanation alert before asking for permissions.
coordinator.showAlert(
.pushNotificationsInformation { [services] in
Expand All @@ -228,6 +234,11 @@ extension VaultListProcessor {
} catch {
self.services.errorReporter.log(error: error)
}
}, onDismissed: {
Task {
self.isShowingNotificationPermissions = false
await self.checkUnassignedCiphers()
}
fedemkr marked this conversation as resolved.
Show resolved Hide resolved
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ class VaultListProcessorTests: BitwardenTestCase { // swiftlint:disable:this typ
)
}

/// `perform(_:)` with `.appeared` checks for unassigned ciphers.
func test_perform_appeared_unassignedCiphers() async throws {
fedemkr marked this conversation as resolved.
Show resolved Hide resolved
stateService.activeAccount = .fixture()
notificationService.authorizationStatus = .authorized
vaultRepository.shouldShowUnassignedCiphersAlert = true

await subject.perform(.appeared)

let alert = try XCTUnwrap(coordinator.alertShown.last)
XCTAssertEqual(alert, .unassignedCiphers {})
}

/// `perform(_:)` with `.morePressed` shows the appropriate more options alert for a card cipher.
func test_perform_morePressed_card() async throws {
let account = Account.fixture()
Expand Down
Loading