From 63b3076d648749335cf781b7aea11bcbd42c6cc2 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 18 Sep 2024 00:52:06 +0200 Subject: [PATCH] refac --- src/lib/components/workspace/Models.svelte | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/lib/components/workspace/Models.svelte b/src/lib/components/workspace/Models.svelte index ce70fbe50..7c2b80fd4 100644 --- a/src/lib/components/workspace/Models.svelte +++ b/src/lib/components/workspace/Models.svelte @@ -95,6 +95,29 @@ }; const moveToTopHandler = async (model) => { + // find models with position 0 and set them to 1 + const topModels = _models.filter((m) => m.info?.meta?.position === 0); + for (const m of topModels) { + let info = m.info; + if (!info) { + info = { + id: m.id, + name: m.name, + meta: { + position: 1 + }, + params: {} + }; + } + + info.meta = { + ...info.meta, + position: 1 + }; + + await updateModelById(localStorage.token, info.id, info); + } + let info = model.info; if (!info) {