Skip to content

Swap to using cipher list view #1124

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
51 changes: 26 additions & 25 deletions BitwardenShared/Core/Vault/Helpers/CipherMatchingHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CipherMatchingHelper {
/// - ciphers: The list of ciphers to filter.
/// - Returns: The list of ciphers that match the URI.
///
func ciphersMatching(uri: String?, ciphers: [CipherView]) async -> [CipherView] {
func ciphersMatching(uri: String?, ciphers: [CipherListView]) async -> [CipherListView] {
guard let uri else { return [] }

let matchURL = URL(string: uri)
Expand All @@ -64,30 +64,31 @@ class CipherMatchingHelper {
matchUri: uri
)
let defaultMatchType = await (try? stateService.getDefaultUriMatchType()) ?? .domain

let matchingCiphers = ciphers.reduce(
into: (exact: [CipherView], fuzzy: [CipherView])([], [])
) { result, cipher in
let match = checkForCipherMatch(
cipher: cipher,
defaultMatchType: defaultMatchType,
isApp: matchIsApp,
matchUri: uri,
matchingDomains: matchingDomains,
matchingFuzzyDomains: matchingFuzzyDomains
)
switch match {
case .exact:
result.exact.append(cipher)
case .fuzzy:
result.fuzzy.append(cipher)
case .none:
// No-op: don't add non-matching ciphers.
break
}
}

return matchingCiphers.exact + matchingCiphers.fuzzy
return []
// let matchingCiphers = ciphers.reduce(
// into: (exact: [CipherView], fuzzy: [CipherView])([], [])
// ) { result, cipher in
// let match = checkForCipherMatch(
// cipher: cipher,
// defaultMatchType: defaultMatchType,
// isApp: matchIsApp,
// matchUri: uri,
// matchingDomains: matchingDomains,
// matchingFuzzyDomains: matchingFuzzyDomains
// )
// switch match {
// case .exact:
// result.exact.append(cipher)
// case .fuzzy:
// result.fuzzy.append(cipher)
// case .none:
// // No-op: don't add non-matching ciphers.
// break
// }
// }
//
// return matchingCiphers.exact + matchingCiphers.fuzzy
//
}

// MARK: Private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension VaultFilterType {
/// - Parameter cipher: The `CipherView` to determine if it should be in the vault list.
/// - Returns: Whether the cipher should be displayed in the vault list.
///
func cipherFilter(_ cipher: CipherView) -> Bool {
func cipherFilter(_ cipher: CipherListView) -> Bool {
switch self {
case .allVaults:
true
Expand Down Expand Up @@ -82,7 +82,7 @@ extension VaultFilterType {
/// - ciphers: The `CipherView` objects used to determine if a folder is empty.
/// - Returns: Whether the folder should be displayed in the vault list.
///
func folderFilter(_ folder: FolderView, ciphers: [CipherView]) -> Bool {
func folderFilter(_ folder: FolderView, ciphers: [CipherListView]) -> Bool {
switch self {
case .allVaults:
return true
Expand Down
Loading
Loading