From b20a14ce7cf39532c54d8467e6d3ba32df24289b Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Sat, 18 May 2024 06:17:47 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81=E6=96=B0=E3=81=97?= =?UTF-8?q?=E3=81=84=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82=E3=83=80?= =?UTF-8?q?=E3=83=BC=E3=82=AF=E3=83=A2=E3=83=BC=E3=83=89=E3=81=A8=E5=AE=8C?= =?UTF-8?q?=E4=BA=86=E6=B8=88=E3=81=BF=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0?= =?UTF-8?q?=E3=81=AE=E9=9D=9E=E8=A1=A8=E7=A4=BA=E8=A8=AD=E5=AE=9A=E3=82=92?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=99=E3=83=BC=E3=82=B9=E3=81=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=82=82=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 10 +++++-- package.json | 3 +- src/components/MenuSettings.tsx | 7 +++-- src/components/ResponsiveDrawer.tsx | 7 +++-- src/hooks/useIndexedDb.ts | 45 +++++++---------------------- src/hooks/useObserve.ts | 7 ++++- 6 files changed, 37 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3d8abd3..afea934 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tasktree-s", - "version": "1.2.3", + "version": "1.2.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tasktree-s", - "version": "1.2.3", + "version": "1.2.4", "dependencies": { "@capacitor-firebase/authentication": "^5.4.1", "@capacitor/android": "^5.7.4", @@ -36,6 +36,7 @@ "react-dom": "^18.2.0", "react-markdown": "^9.0.1", "react-router-dom": "^6.22.3", + "upgrade": "^1.1.0", "zustand": "^4.5.2" }, "devDependencies": { @@ -10685,6 +10686,11 @@ "node": ">=8" } }, + "node_modules/upgrade": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/upgrade/-/upgrade-1.1.0.tgz", + "integrity": "sha512-NtkVvqVCqsJo5U3mYRum2Tw6uCltOxfIJ/AfTZeTmw6U39IB5X23xF+kRZ9aiPaORqeiQQ7Q209/ibhOvxzwHA==" + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 9f75a7c..4cac789 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tasktree-s", "private": true, - "version": "1.2.3", + "version": "1.2.4", "type": "module", "scripts": { "dev": "vite", @@ -38,6 +38,7 @@ "react-dom": "^18.2.0", "react-markdown": "^9.0.1", "react-router-dom": "^6.22.3", + "upgrade": "^1.1.0", "zustand": "^4.5.2" }, "devDependencies": { diff --git a/src/components/MenuSettings.tsx b/src/components/MenuSettings.tsx index 0d40453..c3c2366 100644 --- a/src/components/MenuSettings.tsx +++ b/src/components/MenuSettings.tsx @@ -20,6 +20,7 @@ import DownloadIcon from '@mui/icons-material/Download'; import DeleteForeverIcon from '@mui/icons-material/DeleteForever'; import { useAppStateManagement } from '../hooks/useAppStateManagement'; import { useTreeManagement } from '../hooks/useTreeManagement'; +import { useIndexedDb } from '../hooks/useIndexedDb'; import { useAppStateStore } from '../store/appStateStore'; import { useTreeStateStore } from '../store/treeStateStore'; import { Capacitor } from '@capacitor/core'; @@ -35,6 +36,7 @@ export function MenuSettings({ handleLogout }: { handleLogout: () => void }) { const currentTree = useTreeStateStore((state) => state.currentTree); const { saveAppSettingsDb } = useAppStateManagement(); + const { saveSettingsIdb } = useIndexedDb(); const { handleDownloadAllTrees, handleFileUpload, handleDownloadTreeState } = useTreeManagement(); const open = Boolean(anchorEl); @@ -237,8 +239,9 @@ export function MenuSettings({ handleLogout }: { handleLogout: () => void }) { control={ { - saveAppSettingsDb(!darkMode, hideDoneItems); + onChange={async () => { + await saveSettingsIdb(!darkMode, hideDoneItems); + await saveAppSettingsDb(!darkMode, hideDoneItems); setDarkMode(!darkMode); }} /> diff --git a/src/components/ResponsiveDrawer.tsx b/src/components/ResponsiveDrawer.tsx index 12722bb..76ebd40 100644 --- a/src/components/ResponsiveDrawer.tsx +++ b/src/components/ResponsiveDrawer.tsx @@ -24,6 +24,7 @@ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import ClearIcon from '@mui/icons-material/Clear'; import { UniqueIdentifier } from '@dnd-kit/core'; import { useAppStateManagement } from '../hooks/useAppStateManagement'; +import { useIndexedDb } from '../hooks/useIndexedDb'; import { useAppStateStore } from '../store/appStateStore'; import { useTreeStateStore } from '../store/treeStateStore'; import { useTreeManagement } from '../hooks/useTreeManagement'; @@ -50,6 +51,7 @@ export function ResponsiveDrawer({ handleLogout }: { handleLogout: () => void }) const treesList = useTreeStateStore((state) => state.treesList); const { saveAppSettingsDb } = useAppStateManagement(); + const { saveSettingsIdb } = useIndexedDb(); const { loadCurrentTreeData, handleCreateNewTree } = useTreeManagement(); const { handlePrevButtonClick, handleNextButtonClick } = useSearch(); @@ -174,9 +176,10 @@ export function ResponsiveDrawer({ handleLogout }: { handleLogout: () => void }) control={ ) => { + onChange={async (event: React.ChangeEvent) => { setHideDoneItems(event.target.checked); - saveAppSettingsDb(darkMode, event.target.checked); + await saveSettingsIdb(darkMode, event.target.checked); + await saveAppSettingsDb(darkMode, event.target.checked); }} /> } diff --git a/src/hooks/useIndexedDb.ts b/src/hooks/useIndexedDb.ts index 97a8d24..921cc15 100644 --- a/src/hooks/useIndexedDb.ts +++ b/src/hooks/useIndexedDb.ts @@ -129,8 +129,7 @@ export const useIndexedDb = () => { try { const appState = await idb.appstate.get(1); if (appState) { - setQuickMemoText(appState.quickMemo); - setTreesList(appState.treesList); + setIsLoadedMemoFromDb(true); setDarkMode(appState.settings.darkMode); setHideDoneItems(appState.settings.hideDoneItems); setLocalTimestamp(appState.timestamp); @@ -171,36 +170,6 @@ export const useIndexedDb = () => { } }; - // IndexedデータベースからDarkMode設定を読み込む ------------------------------------------------ - const loadDarkModeFromIdb = async () => { - if (!uid) { - return; - } - try { - const appState = await idb.appstate.get(1); - if (appState) { - setDarkMode(appState.settings.darkMode); - } - } catch (error) { - handleError(error); - } - }; - - // Indexedデータベースから完了済みアイテムの非表示設定を読み込む ------------------------------------------------ - const loadHideDoneItemsFromIdb = async () => { - if (!uid) { - return; - } - try { - const appState = await idb.appstate.get(1); - if (appState) { - setHideDoneItems(appState.settings.hideDoneItems); - } - } catch (error) { - handleError(error); - } - }; - // Indexedデータベースから指定されたツリーのデータを読み込む ------------------------------------------------ const loadCurrentTreeDataFromIdb = async (targetTree: UniqueIdentifier) => { if (!uid || !targetTree) { @@ -221,6 +190,15 @@ export const useIndexedDb = () => { } }; + // Indexedデータベースに設定を保存 ------------------------------------------------ + const saveSettingsIdb = async (darkMode: boolean, hideDoneItems: boolean) => { + try { + await idb.appstate.update(1, { settings: { darkMode, hideDoneItems } }); + } catch (error) { + handleError(error); + } + }; + // IndexedデータベースにItemsを保存 ------------------------------------------------ const saveItemsIdb = async (newItems: TreeItems, targetTree: UniqueIdentifier) => { if (!uid || !targetTree || !newItems) { @@ -462,9 +440,8 @@ export const useIndexedDb = () => { loadSettingsFromIdb, loadQuickMemoFromIdb, loadTreesListFromIdb, - loadDarkModeFromIdb, - loadHideDoneItemsFromIdb, loadCurrentTreeDataFromIdb, + saveSettingsIdb, saveItemsIdb, saveTreesListIdb, saveCurrentTreeNameIdb, diff --git a/src/hooks/useObserve.ts b/src/hooks/useObserve.ts index 84e934a..687072e 100644 --- a/src/hooks/useObserve.ts +++ b/src/hooks/useObserve.ts @@ -14,6 +14,8 @@ import { useDialogStore } from '../store/dialogStore'; import { Preferences } from '@capacitor/preferences'; export const useObserve = () => { + const darkMode = useAppStateStore((state) => state.darkMode); + const hideDoneItems = useAppStateStore((state) => state.hideDoneItems); const isOffline = useAppStateStore((state) => state.isOffline); const uid = useAppStateStore((state) => state.uid); const setLocalTimestamp = useAppStateStore((state) => state.setLocalTimestamp); @@ -40,12 +42,13 @@ export const useObserve = () => { checkAndSyncDb, loadSettingsFromIdb, loadTreesListFromIdb, + saveSettingsIdb, saveItemsIdb, saveTreesListIdb, saveQuickMemoIdb, copyTreeDataToIdbFromDb } = useIndexedDb(); - const { loadQuickMemoFromDb, saveQuickMemoDb } = useAppStateManagement(); + const { loadSettingsFromDb, loadQuickMemoFromDb, saveQuickMemoDb } = useAppStateManagement(); const { handleError } = useError(); const isConnected = useFirebaseConnection(); @@ -96,6 +99,8 @@ export const useObserve = () => { const newTreesList = await loadTreesListFromDb(uid); setTreesList(newTreesList); await saveTreesListIdb(newTreesList); + await loadSettingsFromDb(); + await saveSettingsIdb(darkMode, hideDoneItems); await loadQuickMemoFromDb(); // treesListを反復して、タイムスタンプをチェックし、最新のツリーをコピー const treeIds = newTreesList.map((tree) => tree.id); From 1d7aa183cb74b897a9430c685e96275520acc87a Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Sat, 18 May 2024 06:53:43 +0900 Subject: [PATCH 2/5] Add divider color to dark theme --- src/theme/mui_theme.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/theme/mui_theme.tsx b/src/theme/mui_theme.tsx index 329742d..2b1fe2f 100644 --- a/src/theme/mui_theme.tsx +++ b/src/theme/mui_theme.tsx @@ -123,6 +123,7 @@ export const darkTheme = createTheme({ secondary: { main: '#ef0a0a', }, + divider: 'rgba(255, 255, 255, 0.23)', }, typography: typographyStyles, components: { From 684d8c11dc0118b03a620e2c6f70b1ec73a65830 Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Sat, 18 May 2024 06:57:27 +0900 Subject: [PATCH 3/5] =?UTF-8?q?divider=E3=81=AE=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/theme/mui_theme.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/mui_theme.tsx b/src/theme/mui_theme.tsx index 2b1fe2f..d850625 100644 --- a/src/theme/mui_theme.tsx +++ b/src/theme/mui_theme.tsx @@ -123,7 +123,7 @@ export const darkTheme = createTheme({ secondary: { main: '#ef0a0a', }, - divider: 'rgba(255, 255, 255, 0.23)', + divider: 'rgba(255, 255, 255, 0.18)', }, typography: typographyStyles, components: { From 4fd4247a5ab467ae1da5c116c017f35a58170680 Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Sat, 18 May 2024 07:03:44 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E3=81=A8=E3=83=90=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=B3=E5=90=8D=E3=82=92=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index c128b69..b214bf3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.tasktrees.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 8 - versionName "1.2.3" + versionCode 9 + versionName "1.2.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. From 94601390eb15b8d7dcea5edd74dadb21f8b7ef81 Mon Sep 17 00:00:00 2001 From: Jun Murakami <126404131+Jun-Murakami@users.noreply.github.com> Date: Sat, 18 May 2024 07:11:47 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=921.2.2=E3=81=8B=E3=82=891.2.4=E3=81=AB?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= =?UTF-8?q?=E8=BB=BD=E5=BE=AE=E3=81=AA=E3=83=90=E3=82=B0=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/version.json b/public/version.json index 500931b..b758bad 100644 --- a/public/version.json +++ b/public/version.json @@ -1,4 +1,4 @@ { - "version": "1.2.2", + "version": "1.2.4", "message": "軽微なバグを修正しました。" }