From 5c08893db0a01d7820f514060750d27df0f01162 Mon Sep 17 00:00:00 2001 From: Brian McGee Date: Wed, 20 Aug 2025 10:34:53 +0100 Subject: [PATCH] fix(ui): de-duplicate clan uris when adding to local storage --- pkgs/clan-app/ui/src/stores/clan.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/clan-app/ui/src/stores/clan.ts b/pkgs/clan-app/ui/src/stores/clan.ts index 658df6dbc..3eaa591a3 100644 --- a/pkgs/clan-app/ui/src/stores/clan.ts +++ b/pkgs/clan-app/ui/src/stores/clan.ts @@ -59,8 +59,20 @@ const clanURIs = (): string[] => store.clanURIs; * */ const addClanURI = (uri: string) => { - setStore("clanURIs", store.clanURIs.length, uri); - setStore("sceneData", uri, {}); // Initialize empty scene data for every new clan URI + setStore( + produce((state) => { + // check if it's already in the list + if (state.clanURIs.find((clanURI) => clanURI == uri)) { + return; + } + + // otherwise add it + state.clanURIs = [...state.clanURIs, uri]; + + // initiliase empty scene data + state.sceneData[uri] = {}; + }), + ); }; /**