From 9bdaea0b1bbf24266d4369e195b2cdec4eb6e67a Mon Sep 17 00:00:00 2001 From: thekiwismarthome Date: Wed, 25 Feb 2026 08:19:29 +1300 Subject: [PATCH 1/2] refactor: Replace `storage.get_all_products()` with `storage.get_products()` for product retrieval. --- custom_components/shopping_list_manager/websocket/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/shopping_list_manager/websocket/handlers.py b/custom_components/shopping_list_manager/websocket/handlers.py index edd5bff..68e0d99 100644 --- a/custom_components/shopping_list_manager/websocket/handlers.py +++ b/custom_components/shopping_list_manager/websocket/handlers.py @@ -146,7 +146,7 @@ async def ws_get_products_by_ids( product_ids = set(msg["product_ids"]) # Get all products from storage - all_products = storage.get_all_products() + all_products = storage.get_products() products = [ product.to_dict() From 11180db0e38a5bad6e101429e713dc0ef8b1027b Mon Sep 17 00:00:00 2001 From: thekiwismarthome Date: Wed, 25 Feb 2026 21:54:33 +1300 Subject: [PATCH 2/2] feat: rebuild product search engine immediately after adding a new product --- custom_components/shopping_list_manager/storage.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom_components/shopping_list_manager/storage.py b/custom_components/shopping_list_manager/storage.py index d55734a..c02f5dd 100644 --- a/custom_components/shopping_list_manager/storage.py +++ b/custom_components/shopping_list_manager/storage.py @@ -460,6 +460,9 @@ class ShoppingListStorage: ) self._products[new_product.id] = new_product await self._save_products() + # Rebuild search engine so the new product is immediately searchable + products_dict = {pid: p.to_dict() for pid, p in self._products.items()} + self._search_engine = ProductSearch(products_dict) _LOGGER.debug("Added product: %s", new_product.name) return new_product