Skip to content

Commit 7271afa

Browse files
committed
refactor(config): centralize app config in Dexie
Migrates scattered configuration items and last document locations from the legacy `config` table to new, dedicated Dexie stores. - Introduces a singleton `app-config` table (`AppConfigRow`) to standardize and structure all application settings in a single object. - Creates a `last-locations` table for efficient storage of document read positions. - Updates `ConfigContext` to utilize `dexie-react-hooks`' `useLiveQuery` for reactive and simplified state management. - Implements a database upgrade path (from DB_VERSION 4 to 5) to migrate all existing user settings seamlessly. - Simplifies config access and updates with new `getAppConfig` and `updateAppConfig` utility functions. - Removes the deprecated `config` table after successful migration. - Updates consumers like `SettingsModal` and test helpers to align with the new config structure.
1 parent d1dd3bd commit 7271afa

File tree

6 files changed

+341
-370
lines changed

6 files changed

+341
-370
lines changed

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
/* Fail the build on CI if you accidentally left test.only in the source code. */
1212
forbidOnly: !!process.env.CI,
1313
retries: process.env.CI ? 2 : 0,
14-
workers: process.env.CI ? '100%' : '50%',
14+
// workers: '50%',
1515
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
1616
reporter: 'html',
1717
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */

src/components/SettingsModal.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
import { useTheme } from '@/contexts/ThemeContext';
2323
import { useConfig } from '@/contexts/ConfigContext';
2424
import { ChevronUpDownIcon, CheckIcon, SettingsIcon } from '@/components/icons/Icons';
25-
import { syncDocumentsToServer, loadDocumentsFromServer, setItem, getItem } from '@/utils/dexie';
25+
import { syncDocumentsToServer, loadDocumentsFromServer, getFirstVisit, setFirstVisit } from '@/utils/dexie';
2626
import { useDocuments } from '@/contexts/DocumentContext';
2727
import { ConfirmDialog } from '@/components/ConfirmDialog';
2828
import { ProgressPopup } from '@/components/ProgressPopup';
@@ -122,9 +122,9 @@ export function SettingsModal() {
122122
// set firstVisit on initial load
123123
const checkFirstVist = useCallback(async () => {
124124
if (!isDev) return;
125-
const firstVisit = await getItem('firstVisit');
126-
if (firstVisit == null) {
127-
await setItem('firstVisit', 'true');
125+
const firstVisit = await getFirstVisit();
126+
if (!firstVisit) {
127+
await setFirstVisit(true);
128128
setIsOpen(true);
129129
}
130130
}, [setIsOpen]);

0 commit comments

Comments
 (0)