From fc7a7aa54dbc49263c15e1495bdbdb8298976d49 Mon Sep 17 00:00:00 2001 From: Alexis Faizeau Date: Fri, 6 May 2022 15:27:55 +0200 Subject: [PATCH] Fix uiWebsite updating --- front/src/Phaser/Game/UI/UIWebsiteManager.ts | 2 ++ front/src/Stores/UIWebsiteStore.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/front/src/Phaser/Game/UI/UIWebsiteManager.ts b/front/src/Phaser/Game/UI/UIWebsiteManager.ts index ce3bb0d6..a717138d 100644 --- a/front/src/Phaser/Game/UI/UIWebsiteManager.ts +++ b/front/src/Phaser/Game/UI/UIWebsiteManager.ts @@ -59,6 +59,8 @@ class UIWebsiteManager { website.margin.right = websiteEvent.margin.right; } } + + uiWebsitesStore.update(website); }); } diff --git a/front/src/Stores/UIWebsiteStore.ts b/front/src/Stores/UIWebsiteStore.ts index 37c17156..92fccd11 100644 --- a/front/src/Stores/UIWebsiteStore.ts +++ b/front/src/Stores/UIWebsiteStore.ts @@ -11,6 +11,11 @@ function createUIWebsiteStore() { add: (uiWebsite: UIWebsite) => { update((currentArray) => [...currentArray, uiWebsite]); }, + update: (uiWebsite: UIWebsite) => { + update((currentArray) => + currentArray.map((currentWebsite) => (currentWebsite.id === uiWebsite.id ? uiWebsite : currentWebsite)) + ); + }, remove: (uiWebsite: UIWebsite) => { update((currentArray) => currentArray.filter((currentWebsite) => currentWebsite.id !== uiWebsite.id)); },