diff --git a/CHANGELOG.md b/CHANGELOG.md
index db74888..0dc5b7e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- Reset input when escape key is pressed
- Implement audit logging
+- Save collapsed state of book navigation items
## [0.26.6] - 2024-06-10
diff --git a/package-lock.json b/package-lock.json
index 967b1d2..f346009 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -38,6 +38,7 @@
"eslint-plugin-vue": "^9.9.0",
"glob": "^8.0.3",
"jsdom": "^20.0.0",
+ "localforage": "^1.10.0",
"postcss": "^8.4.14",
"prettier": "^3.0.3",
"release-it": "^16.2.1",
@@ -6235,6 +6236,13 @@
"node": ">= 4"
}
},
+ "node_modules/immediate": {
+ "version": "3.0.6",
+ "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
+ "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/immutable": {
"version": "4.3.5",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.5.tgz",
@@ -7554,6 +7562,16 @@
"node": ">= 0.8.0"
}
},
+ "node_modules/lie": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
+ "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "immediate": "~3.0.5"
+ }
+ },
"node_modules/lilconfig": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz",
@@ -7601,6 +7619,16 @@
"url": "https://github.com/sponsors/antfu"
}
},
+ "node_modules/localforage": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz",
+ "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "lie": "3.1.1"
+ }
+ },
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
diff --git a/package.json b/package.json
index 2f44d2d..8aac248 100644
--- a/package.json
+++ b/package.json
@@ -49,6 +49,7 @@
"eslint-plugin-vue": "^9.9.0",
"glob": "^8.0.3",
"jsdom": "^20.0.0",
+ "localforage": "^1.10.0",
"postcss": "^8.4.14",
"prettier": "^3.0.3",
"release-it": "^16.2.1",
diff --git a/src/components/BookNavigationItem.vue b/src/components/BookNavigationItem.vue
index b998dc6..bc82533 100644
--- a/src/components/BookNavigationItem.vue
+++ b/src/components/BookNavigationItem.vue
@@ -23,7 +23,7 @@
:loading="isLoading"
:undo="isDeleting"
:open="isOpen"
- @update:open="(open: boolean) => (isOpen = open)"
+ @update:open="handleUpdateOpenStatus"
@update:name="handleUpdateBookName"
@undo="handleUndo"
>
@@ -121,7 +121,14 @@
diff --git a/src/utils/useLocalForage.ts b/src/utils/useLocalForage.ts
new file mode 100644
index 0000000..456e3f3
--- /dev/null
+++ b/src/utils/useLocalForage.ts
@@ -0,0 +1,30 @@
+import localforage from 'localforage';
+
+export function useLocalForage(
+ storageKey: string,
+ storeName = 'settings'
+): {
+ setItemInKey: (itemId: number, value: T) => Promise;
+ getItemInKey: (itemId: number) => Promise;
+} {
+ localforage.config({
+ name: 'money',
+ storeName
+ });
+
+ return {
+ getItemInKey: async (itemId): Promise => {
+ const keyValue = await localforage.getItem>(storageKey);
+
+ return keyValue?.[itemId];
+ },
+ setItemInKey: async (itemId, value): Promise => {
+ const status = await localforage.getItem>(storageKey);
+
+ await localforage.setItem('bookCollapsedStatus', {
+ ...status,
+ [itemId]: value
+ });
+ }
+ };
+}