mirror of https://github.com/Wox-launcher/Wox
feat(ui): enhance item update logic with active filter handling
* Added logic to reapply filters when updating an item if an active filter exists. * Ensured items are updated directly when no filter is active. * Updated `updateItems` method to filter items based on the current filter text after updating the original items.
This commit is contained in:
parent
b0a1405d12
commit
872e2873be
|
@ -197,20 +197,23 @@ class WoxListController<T> extends GetxController {
|
||||||
_originalItems[originalIndex] = item;
|
_originalItems[originalIndex] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update items
|
// Check if there's an active filter
|
||||||
final index = _items.indexWhere((element) => element.value.id == item.id);
|
bool hasActiveFilter = filterBoxController.text.isNotEmpty;
|
||||||
if (index != -1) {
|
if (hasActiveFilter) {
|
||||||
_items[index] = item.obs;
|
// If there's an active filter, reapply it to ensure the updated item is properly filtered
|
||||||
|
filterItems(traceId, filterBoxController.text);
|
||||||
|
} else {
|
||||||
|
// No filter active, update items directly
|
||||||
|
final index = _items.indexWhere((element) => element.value.id == item.id);
|
||||||
|
if (index != -1) {
|
||||||
|
_items[index] = item.obs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateItems(String traceId, List<WoxListItem<T>> newItems) {
|
void updateItems(String traceId, List<WoxListItem<T>> newItems) {
|
||||||
_items.assignAll(newItems.map((item) => item.obs));
|
|
||||||
_originalItems.assignAll(newItems);
|
_originalItems.assignAll(newItems);
|
||||||
|
filterItems(traceId, filterBoxController.text);
|
||||||
if (_activeIndex.value >= _items.length && _items.isNotEmpty) {
|
|
||||||
updateActiveIndex(traceId, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateHoveredIndex(int index) {
|
void updateHoveredIndex(int index) {
|
||||||
|
|
Loading…
Reference in New Issue