diff --git a/src/lib/ListItem.svelte b/src/lib/ListItem.svelte
index 527235e..2df45c8 100644
--- a/src/lib/ListItem.svelte
+++ b/src/lib/ListItem.svelte
@@ -1,13 +1,10 @@
@@ -16,12 +13,24 @@
{completed}/{list.tasks.length}
-
-
+
+
+
+
+
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 5487926..aff15d6 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -1,6 +1,7 @@
-import { alphabet, generateRandomString } from "oslo/crypto";
-import { local_lists } from "./stores.svelte";
import { goto } from "$app/navigation";
+import toast from "svelte-french-toast";
+import { local_lists, pinned_list, type List } from "./stores.svelte";
+import { alphabet, generateRandomString } from "oslo/crypto";
export function generateId() {
return generateRandomString(10, alphabet("a-z", "0-9"));
@@ -29,5 +30,18 @@ export function createList() {
};
local_lists.current!.push(new_list);
- goto(`/${new_list.id}`);
+ return { id: new_list.id };
+}
+
+export function deleteList(id: string) {
+ if (pinned_list.current === id) {
+ toast.error("Cannot delete pinned list");
+ return;
+ }
+
+ local_lists.current = local_lists.current.filter((l) => l.id !== id);
+}
+
+export function pinList(id: string) {
+ pinned_list.current = id;
}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index ec86dbd..1114f00 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -2,6 +2,7 @@
import ListItem from "$lib/ListItem.svelte";
import { createList } from "$lib/utils";
import { user_preferences, local_lists } from "$lib/stores.svelte";
+ import { goto } from "$app/navigation";
@@ -11,7 +12,7 @@
{#each local_lists.current as list}
{/each}
-
-
+ deleteList(page.params.id!)}>
{
- switchToList(user_list.id)
+ goto(`/${user_list.id}`);
is_menu_open = false;
}}
class="flex gap-2 justify-between text-start w-full h-full rounded-xl pl-2 pr-5 py-2 hover:bg-slate-500/10 transition-all duration-150 items-center"