refac: frontend

This commit is contained in:
Timothy Jaeryang Baek
2024-11-15 02:05:43 -08:00
parent 2ab5b2fd71
commit d9dc04f1a1
20 changed files with 1340 additions and 1407 deletions
@@ -5,7 +5,7 @@
import { models } from '$lib/stores';
import { onMount, tick, getContext } from 'svelte';
import { addNewModel, getModelById, getModelInfos } from '$lib/apis/models';
import { createNewModel, getModelById } from '$lib/apis/models';
import { getModels } from '$lib/apis';
import ModelEditor from '$lib/components/workspace/Models/ModelEditor.svelte';
@@ -21,7 +21,7 @@
}
if (modelInfo) {
const res = await addNewModel(localStorage.token, {
const res = await createNewModel(localStorage.token, {
...modelInfo,
meta: {
...modelInfo.meta,
@@ -8,17 +8,20 @@
import { page } from '$app/stores';
import { models } from '$lib/stores';
import { updateModelById } from '$lib/apis/models';
import { getModelById, updateModelById } from '$lib/apis/models';
import { getModels } from '$lib/apis';
import ModelEditor from '$lib/components/workspace/Models/ModelEditor.svelte';
let model = null;
onMount(() => {
onMount(async () => {
const _id = $page.url.searchParams.get('id');
if (_id) {
model = $models.find((m) => m.id === _id && m?.owned_by !== 'arena');
model = await getModelById(localStorage.token, _id).catch((e) => {
return null;
});
if (!model) {
goto('/workspace/models');
}