From 09ea799ad4ce3e90060cbca1e984ec75fb84a739 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sun, 3 Dec 2023 03:33:02 +0100 Subject: [PATCH] Studio: some fixes, show user id when running localhost --- src/UI/Studio/EditItemButton.svelte | 51 +++++++++++++++++------------ src/UI/Studio/EditLayerState.ts | 16 ++++++++- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/src/UI/Studio/EditItemButton.svelte b/src/UI/Studio/EditItemButton.svelte index 3d593f0a1..f5f1c1001 100644 --- a/src/UI/Studio/EditItemButton.svelte +++ b/src/UI/Studio/EditItemButton.svelte @@ -1,29 +1,30 @@ dispatch("layerSelected", info)}> @@ -32,6 +33,14 @@ {info.id} {#if info.owner && info.owner !== $selfId} - (made by {$displayName ?? info.owner}) + {#if $displayName} + (made by {$displayName} + {#if window.location.host.startsWith("127.0.0.1")} + - {info.owner} + {/if} + ) + {:else } + ({info.owner}) + {/if} {/if} diff --git a/src/UI/Studio/EditLayerState.ts b/src/UI/Studio/EditLayerState.ts index 75e821a9d..7a7d7f7ba 100644 --- a/src/UI/Studio/EditLayerState.ts +++ b/src/UI/Studio/EditLayerState.ts @@ -299,6 +299,9 @@ export default class EditLayerState extends EditJsonState { function cleanArray(data: object, key: string): boolean{ + if(!data){ + return false + } if (data[key]) { // A bit of cleanup const lBefore = data[key].length @@ -312,7 +315,18 @@ export default class EditLayerState extends EditJsonState { } this.configuration.addCallbackAndRunD((layer) => { - const changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings") + let changed = cleanArray(layer, "tagRenderings") || cleanArray(layer, "pointRenderings") + for (const tr of layer.tagRenderings ?? []) { + if(typeof tr === "string"){ + continue + } + + const qtr = ( tr) + if(qtr.freeform && Object.keys(qtr.freeform ).length === 0){ + delete qtr.freeform + changed = true + } + } if(changed){ this.configuration.ping() }