From 8b329a51daab79df02a76daa1dc1e051339aa764 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 7 Oct 2025 15:48:44 +0200 Subject: [PATCH] show toasts --- lib/src/Components/Map/hooks/useItems.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/src/Components/Map/hooks/useItems.tsx b/lib/src/Components/Map/hooks/useItems.tsx index 7c4ac890..b403beb1 100644 --- a/lib/src/Components/Map/hooks/useItems.tsx +++ b/lib/src/Components/Map/hooks/useItems.tsx @@ -141,15 +141,19 @@ function useItemsManager(initialItems: Item[]): { for (const layer of layersRef.current) { if (layer.api) { - try { - const result = await layer.api.getItems() - result.map((item) => { - dispatch({ type: 'ADD', item: { ...item, layer } }) - return null - }) - } catch (error) { - console.error(`Failed to reload items for layer ${layer.name}:`, error) - } + const result = await toast.promise(layer.api.getItems(), { + pending: `loading ${layer.name} ...`, + success: `${layer.name} loaded`, + error: { + render({ data }) { + return `${data}` + }, + }, + }) + result.map((item) => { + dispatch({ type: 'ADD', item: { ...item, layer } }) + return null + }) } }