Skip to content

Commit

Permalink
fix(hierarchical): Hierarchical facets clearing (#252)
Browse files Browse the repository at this point in the history
* fix issues with hierarchical facets clearing
  • Loading branch information
VladislavFitz authored Sep 27, 2022
1 parent 6862a7e commit 3ba16f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Sources/InstantSearchCore/FilterState/GroupStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ extension GroupsStorage: FiltersWritable {
for groupID in groupIDs {
switch groupID {
case .hierarchical:
filterGroups[groupID] = filterGroups[groupID]?.withFilters([])
if var cleanHierarchicalGroup = filterGroups[groupID]?.withFilters([]) as? FilterGroup.Hierarchical {
cleanHierarchicalGroup.hierarchicalFilters.removeAll()
filterGroups[groupID] = cleanHierarchicalGroup
}
default:
filterGroups.removeValue(forKey: groupID)
}
Expand Down Expand Up @@ -182,7 +185,7 @@ extension GroupsStorage: FiltersWritable {
}

mutating func removeAll() {
filterGroups.removeAll()
removeAll(fromGroupWithIDs: Array(getGroupIDs()))
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public extension HierarchicalInteractor {

}

filterState.onChange.subscribePast(with: interactor) { _, _ in
// TODO
filterState.onChange.subscribePast(with: interactor) { interactor, filterState in
if filterState[hierarchical: groupName].isEmpty {
interactor.selections = []
}
}

}
Expand Down

0 comments on commit 3ba16f7

Please sign in to comment.