diff --git a/apps/mobile/app/common/database/index.js b/apps/mobile/app/common/database/index.js index a7331e2cd..1160372ad 100644 --- a/apps/mobile/app/common/database/index.js +++ b/apps/mobile/app/common/database/index.js @@ -36,11 +36,11 @@ database.host( SSE_HOST: "https://events.streetwriters.co", SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co", ISSUES_HOST: "https://issues.streetwriters.co" - // API_HOST: "http://192.168.43.108:5264", - // AUTH_HOST: "http://192.168.43.108:8264", - // SSE_HOST: "http://192.168.43.108:7264", - // SUBSCRIPTIONS_HOST: "http://192.168.43.108:9264", - // ISSUES_HOST: "http://192.168.43.108:2624" + // API_HOST: "http://192.168.43.5:5264", + // AUTH_HOST: "http://192.168.43.5:8264", + // SSE_HOST: "http://192.168.43.5:7264", + // SUBSCRIPTIONS_HOST: "http://192.168.43.5:9264", + // ISSUES_HOST: "http://192.168.43.5:2624" } : { API_HOST: "https://api.notesnook.com", @@ -61,18 +61,15 @@ database.setup({ }, batchSize: 500, sqliteOptions: { - dialect: { - createDriver: () => - new RNSqliteDriver({ async: true, dbName: "test.db" }), + dialect: (name) => ({ + createDriver: () => { + return new RNSqliteDriver({ async: true, dbName: name }); + }, createAdapter: () => new SqliteAdapter(), createIntrospector: (db) => new SqliteIntrospector(db), createQueryCompiler: () => new SqliteQueryCompiler() - } - // journalMode: "MEMORY", - // synchronous: "normal", - // pageSize: 8192, - // cacheSize: -16000, - // lockingMode: "exclusive" + }), + tempStore: "memory" } }); diff --git a/apps/mobile/app/common/database/sqlite.kysely.ts b/apps/mobile/app/common/database/sqlite.kysely.ts index 1ac2fb407..e4d9e855d 100644 --- a/apps/mobile/app/common/database/sqlite.kysely.ts +++ b/apps/mobile/app/common/database/sqlite.kysely.ts @@ -45,15 +45,15 @@ export class RNSqliteDriver implements Driver { } async beginTransaction(connection: DatabaseConnection): Promise { - await connection.executeQuery(CompiledQuery.raw("begin")); + await connection.executeQuery(CompiledQuery.raw("BEGIN TRANSACTION")); } async commitTransaction(connection: DatabaseConnection): Promise { - await connection.executeQuery(CompiledQuery.raw("commit")); + await connection.executeQuery(CompiledQuery.raw("COMMIT")); } async rollbackTransaction(connection: DatabaseConnection): Promise { - await connection.executeQuery(CompiledQuery.raw("rollback")); + await connection.executeQuery(CompiledQuery.raw("ROLLBACK")); } async releaseConnection(): Promise { diff --git a/apps/mobile/app/components/merge-conflicts/index.js b/apps/mobile/app/components/merge-conflicts/index.js index 3d0c07497..18cff390e 100644 --- a/apps/mobile/app/components/merge-conflicts/index.js +++ b/apps/mobile/app/components/merge-conflicts/index.js @@ -17,9 +17,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +import { getFormattedDate } from "@notesnook/common"; +import { useThemeColors } from "@notesnook/theme"; import KeepAwake from "@sayem314/react-native-keep-awake"; import React, { useEffect, useRef, useState } from "react"; -import { Modal, SafeAreaView, Text, View } from "react-native"; +import { SafeAreaView, Text, View } from "react-native"; import Animated from "react-native-reanimated"; import { db } from "../../common/database"; import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets"; @@ -33,7 +35,7 @@ import { } from "../../services/event-manager"; import Navigation from "../../services/navigation"; import Sync from "../../services/sync"; -import { useThemeColors } from "@notesnook/theme"; +import { useSettingStore } from "../../stores/use-setting-store"; import { eOnLoadNote, eShowMergeDialog } from "../../utils/events"; import { SIZE } from "../../utils/size"; import { sleep } from "../../utils/time"; @@ -45,8 +47,6 @@ import { Button } from "../ui/button"; import { IconButton } from "../ui/icon-button"; import Seperator from "../ui/seperator"; import Paragraph from "../ui/typography/paragraph"; -import { useSettingStore } from "../../stores/use-setting-store"; -import { getFormattedDate } from "@notesnook/common"; const MergeConflicts = () => { const { colors } = useThemeColors(); @@ -62,7 +62,7 @@ const MergeConflicts = () => { const applyChanges = async () => { let _content = keep; - let note = db.notes.note(_content.noteId).data; + let note = await db.notes.note(_content.noteId); await db.notes.add({ id: note.id, conflicted: false, @@ -100,7 +100,7 @@ const MergeConflicts = () => { }; const show = async (item) => { - let noteContent = await db.content.raw(item.contentId); + let noteContent = await db.content.get(item.contentId); content.current = { ...noteContent }; if (__DEV__) { if (!noteContent.conflicted) { @@ -320,7 +320,7 @@ const MergeConflicts = () => { readonly editorId=":conflictPrimary" onLoad={async () => { - const note = db.notes.note(content.current?.noteId)?.data; + const note = await db.notes.note(content.current?.noteId); if (!note) return; await sleep(300); eSendEvent(eOnLoadNote + ":conflictPrimary", { @@ -357,7 +357,7 @@ const MergeConflicts = () => { readonly editorId=":conflictSecondary" onLoad={async () => { - const note = db.notes.note(content.current?.noteId)?.data; + const note = await db.notes.note(content.current?.noteId); if (!note) return; await sleep(300); eSendEvent(eOnLoadNote + ":conflictSecondary", { diff --git a/apps/mobile/app/components/sheets/add-to/index.tsx b/apps/mobile/app/components/sheets/add-to/index.tsx index b28db189b..9de5afe20 100644 --- a/apps/mobile/app/components/sheets/add-to/index.tsx +++ b/apps/mobile/app/components/sheets/add-to/index.tsx @@ -136,7 +136,7 @@ const MoveNoteSheet = ({ const renderNotebook = useCallback( ({ item, index }: { item: string | number; index: number }) => ( - + ), [notebooks] ); diff --git a/apps/mobile/app/components/sheets/add-to/notebook-item.tsx b/apps/mobile/app/components/sheets/add-to/notebook-item.tsx index 88ead4212..bf3b5843b 100644 --- a/apps/mobile/app/components/sheets/add-to/notebook-item.tsx +++ b/apps/mobile/app/components/sheets/add-to/notebook-item.tsx @@ -52,8 +52,10 @@ export const NotebookItem = ({ parent?: NotebookParentProp; items?: VirtualizedGrouping; }) => { - const expanded = useNotebookExpandedStore((state) => state.expanded[id]); - const { nestedNotebooks, notebook: item } = useNotebook(id, items, expanded); + const { nestedNotebooks, notebook: item } = useNotebook(id, items, true); + const expanded = useNotebookExpandedStore((state) => + item?.id ? state.expanded[item?.id] : false + ); const { totalNotes: totalNotes, getTotalNotes } = useTotalNotes("notebook"); const focusedRouteId = useNavigationStore((state) => state.focusedRouteId); const { colors } = useThemeColors("sheet"); @@ -240,8 +242,8 @@ export const NotebookItem = ({ ? null : nestedNotebooks?.ids.map((id, index) => ( . */ -import { GroupHeader, Notebook, VirtualizedGrouping } from "@notesnook/core"; +import { Notebook, VirtualizedGrouping } from "@notesnook/core"; import { useThemeColors } from "@notesnook/theme"; import React, { createContext, @@ -149,7 +149,7 @@ export const NotebookSheet = () => { }) => ( @@ -588,7 +588,7 @@ const NotebookItem = ({ : item && nestedNotebooks?.ids.map((id, index) => ( { "react-native-blob-util": path.join(__dirname, "../node_modules/react-native-blob-util"), "@mdi/js": path.join(__dirname, "../node_modules/@mdi/js/mdi.js"), "katex": path.join(__dirname, "../node_modules/katex"), + "tinycolor2": path.join(__dirname, "../node_modules/tinycolor2"), }, }, /**