This commit is contained in:
Timothy Jaeryang Baek 2024-11-12 22:50:11 -08:00
parent d5435cb8b9
commit 94a0bf90ce

View File

@ -31,7 +31,12 @@
init(); init();
} }
$: if (tools) {
selectedToolIds = Object.keys(tools).filter((toolId) => tools[toolId]?.enabled ?? false);
}
const init = async () => { const init = async () => {
console.log('init');
if ($_tools === null) { if ($_tools === null) {
await _tools.set(await getTools(localStorage.token)); await _tools.set(await getTools(localStorage.token));
} }
@ -76,9 +81,7 @@
<button <button
class="flex w-full justify-between gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl" class="flex w-full justify-between gap-2 items-center px-3 py-2 text-sm font-medium cursor-pointer rounded-xl"
on:click={() => { on:click={() => {
selectedToolIds = tools[toolId].enabled tools[toolId].enabled = !tools[toolId].enabled;
? selectedToolIds.filter((id) => id !== toolId)
: [...selectedToolIds, toolId];
}} }}
> >
<div class="flex-1 truncate"> <div class="flex-1 truncate">
@ -93,7 +96,7 @@
</Tooltip> </Tooltip>
</div> </div>
<div class=" shrink-0 flex-shrink-0"> <div class=" flex-shrink-0">
<Switch state={tools[toolId].enabled} /> <Switch state={tools[toolId].enabled} />
</div> </div>
</button> </button>