diff --git a/resources/ts/App.vue b/resources/ts/App.vue index 559a184..ce0ed18 100644 --- a/resources/ts/App.vue +++ b/resources/ts/App.vue @@ -27,7 +27,8 @@ onMounted(() => {
-

{ class="inline" /> Tout Doux -

+
diff --git a/resources/ts/lib/lists.ts b/resources/ts/lib/lists.ts deleted file mode 100644 index f874f33..0000000 --- a/resources/ts/lib/lists.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { getCookie, setCookie } from "@/lib/cookies"; - -const COOKIE_NAME = "recent-lists"; -const MAX_RECENT_LISTS = 32; - -export function getRecentLists(): string[] { - const rawData = getCookie(COOKIE_NAME, ""); - if (!rawData) { - return []; - } - return rawData.split(","); -} - -export function saveRecentList(list: string): void { - const recentLists = [list] - .concat(getRecentLists()) - .filter((v, i, a) => a.indexOf(v) === i) - .slice(0, MAX_RECENT_LISTS); - setCookie(COOKIE_NAME, recentLists.join(",")); -} diff --git a/resources/ts/stores/lists.ts b/resources/ts/stores/lists.ts new file mode 100644 index 0000000..01a68ed --- /dev/null +++ b/resources/ts/stores/lists.ts @@ -0,0 +1,25 @@ +import { ref } from "vue"; +import { defineStore } from "pinia"; +import { getCookie, setCookie } from "@/lib/cookies"; + +const COOKIE_NAME = "recent-lists"; +const MAX_RECENT_LISTS = 32; + +export const useListStore = defineStore("lists", () => { + const lists = ref([]); + + const rawData = getCookie(COOKIE_NAME, ""); + if (rawData) { + lists.value = rawData.split(","); + } + + function addList(list: string) { + lists.value = [list] + .concat(lists.value) + .filter((v, i, a) => a.indexOf(v) === i) + .slice(0, MAX_RECENT_LISTS); + setCookie(COOKIE_NAME, lists.value.join(",")); + } + + return { lists, addList }; +}); diff --git a/resources/ts/views/HomeView.vue b/resources/ts/views/HomeView.vue index 26a07c2..09a28bb 100644 --- a/resources/ts/views/HomeView.vue +++ b/resources/ts/views/HomeView.vue @@ -1,5 +1,5 @@ @@ -183,7 +202,10 @@ onBeforeRouteUpdate((to) => { :stroke-width="1" /> -
+
@@ -201,7 +223,7 @@ onBeforeRouteUpdate((to) => { v-model="tasks[i]" :show-last-checked="showLastChecked" :show-next-reset="showNextReset" - @updated="updateTitle" + @updated="onUpdateTask" @clone="onCloneTask" @delete="onDeleteTask" />