From 868e2bb5afe4c5a056c1cb3fdaa09df08cca9cfe Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 25 Aug 2022 08:37:28 +0530 Subject: [PATCH] feat: Upload history --- package.json | 4 +- src/lib/components/history/history.svelte | 10 +-- src/lib/components/history/history.ts | 80 ++++++++++++++++++----- src/lib/types.d.ts | 18 +++-- src/lib/util/migrations.ts | 32 +++++++++ src/routes/+layout.svelte | 2 + yarn.lock | 5 ++ 7 files changed, 123 insertions(+), 28 deletions(-) create mode 100644 src/lib/util/migrations.ts diff --git a/package.json b/package.json index 1a3c0fe0..7a606f34 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "@testing-library/svelte": "3.2.1", "@types/mermaid": "8.2.9", "@types/pako": "1.0.3", + "@types/uuid": "^8.3.4", "@typescript-eslint/eslint-plugin": "5.34.0", "@typescript-eslint/parser": "5.34.0", "@vitest/ui": "0.22.1", @@ -75,7 +76,8 @@ "monaco-mermaid": "1.0.6", "pako": "2.0.4", "random-word-slugs": "0.1.6", - "svg-pan-zoom": "^3.6.1" + "svg-pan-zoom": "^3.6.1", + "uuid": "^8.3.2" }, "lint-staged": { "*.{ts,svelte,js,css,md,json}": [ diff --git a/src/lib/components/history/history.svelte b/src/lib/components/history/history.svelte index 3e434fa9..525fa3e6 100644 --- a/src/lib/components/history/history.svelte +++ b/src/lib/components/history/history.svelte @@ -77,11 +77,11 @@ } }; - const clearHistory = (date?: number): void => { - if (!date && !prompt('Clear all saved items?')) { + const clearHistory = (id?: string): void => { + if (!id && !prompt('Clear all saved items?')) { return; } - clearHistoryData(date); + clearHistoryData(id); }; const restoreHistoryItem = (state: State): void => { @@ -147,7 +147,7 @@