feat: add GroupFilterViewModel and GroupFilterView sidebar
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYqycDFsynHH9VnnK7LNSf
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import MyPassCore
|
||||
|
||||
@MainActor
|
||||
final class GroupFilterViewModel: ObservableObject {
|
||||
@Published var selectedGroupIds: Set<UUID> = []
|
||||
|
||||
private let session: VaultSession
|
||||
|
||||
init(session: VaultSession) {
|
||||
self.session = session
|
||||
}
|
||||
|
||||
func isSelected(_ group: MyPassCore.Group) -> Bool {
|
||||
selectedGroupIds.contains(group.id)
|
||||
}
|
||||
|
||||
func toggle(_ group: MyPassCore.Group) {
|
||||
guard let root = session.database?.root else { return }
|
||||
selectedGroupIds = GroupSelection.toggling(group.id, in: root, current: selectedGroupIds)
|
||||
}
|
||||
|
||||
func clear() {
|
||||
selectedGroupIds = []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user