From 37969da3e9ff0c162c0918c2db98baa79fc9b136 Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Tue, 21 Oct 2025 14:02:56 +0530 Subject: [PATCH] fix: Prevent Crash When App Is Closed During Onboarding (Closes #1517) --- src/database/db.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/database/db.ts b/src/database/db.ts index a2f172c4..5e9244b5 100644 --- a/src/database/db.ts +++ b/src/database/db.ts @@ -20,7 +20,6 @@ import { } from './tables/ChapterTable'; import { createRepositoryTableQuery } from './tables/RepositoryTable'; -import { MMKVStorage } from '@utils/mmkv/mmkv'; import { showToast } from '@utils/showToast'; const dbName = 'lnreader.db'; @@ -28,9 +27,6 @@ const dbName = 'lnreader.db'; export const db = SQLite.openDatabaseSync(dbName); export const createTables = () => { - const isOnBoard = MMKVStorage.getBoolean('IS_ONBOARDED'); - - // These values are not persistent and need to be set on every app start db.execSync('PRAGMA busy_timeout = 5000'); db.execSync('PRAGMA cache_size = 10000'); db.execSync('PRAGMA foreign_keys = ON'); @@ -39,7 +35,7 @@ export const createTables = () => { db.getFirstSync<{ user_version: number }>('PRAGMA user_version') ?.user_version ?? 0; - if (!isOnBoard) { + if (userVersion === 0) { db.execSync('PRAGMA journal_mode = WAL'); db.execSync('PRAGMA synchronous = NORMAL'); db.execSync('PRAGMA temp_store = MEMORY'); @@ -58,10 +54,8 @@ export const createTables = () => { db.runSync(createNovelTriggerQueryDelete); db.execSync('PRAGMA user_version = 1'); }); - } else { - if (userVersion < 1) { - updateToDBVersion1(); - } + } else if (userVersion < 1) { + updateToDBVersion1(); } };