This commit is contained in:
Timothy J. Baek 2024-06-11 00:58:52 -07:00
parent 5f29a9edf4
commit fc46532955
2 changed files with 20 additions and 13 deletions

View File

@ -131,7 +131,9 @@
<button
class="self-center w-fit text-sm px-2 py-2 dark:text-gray-300 dark:hover:text-white hover:bg-black/5 dark:hover:bg-white/5 rounded-xl"
type="button"
on:click={async () => {
on:click={async (e) => {
e.stopPropagation();
const _tool = await getToolById(localStorage.token, tool.id).catch((error) => {
toast.error(error);
return null;

View File

@ -6,6 +6,7 @@
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
let mounted = false;
let clone = false;
let tool = null;
@ -30,23 +31,27 @@
};
onMount(() => {
console.log('mounted');
if (sessionStorage.tool) {
tool = JSON.parse(sessionStorage.tool);
sessionStorage.removeItem('tool');
console.log(tool);
clone = true;
}
mounted = true;
});
</script>
<ToolkitEditor
id={tool?.id ?? ''}
name={tool?.name ?? ''}
meta={tool?.meta ?? { description: '' }}
content={tool?.content ?? ''}
{clone}
on:save={(e) => {
saveHandler(e.detail);
}}
/>
{#if mounted}
<ToolkitEditor
id={tool?.id ?? ''}
name={tool?.name ?? ''}
meta={tool?.meta ?? { description: '' }}
content={tool?.content ?? ''}
{clone}
on:save={(e) => {
saveHandler(e.detail);
}}
/>
{/if}