Skip to content

Commit 9d06f0e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into audio-player
2 parents 083f587 + 867af58 commit 9d06f0e

File tree

82 files changed

+630847
-3627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+630847
-3627
lines changed

apps/desktop/package-lock.json

Lines changed: 34 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@notesnook/desktop",
33
"productName": "Notesnook",
44
"description": "Your private note taking space",
5-
"version": "3.2.1",
5+
"version": "3.2.3",
66
"appAppleId": "1544027013",
77
"private": true,
88
"main": "./dist/cjs/index.js",
@@ -30,12 +30,12 @@
3030
"@notesnook/ui": "file:../../packages/ui",
3131
"@trpc/client": "10.45.2",
3232
"@trpc/server": "10.45.2",
33-
"better-sqlite3-multiple-ciphers": "11.3.0",
33+
"better-sqlite3-multiple-ciphers": "^11.10.0",
3434
"electron-trpc": "0.7.1",
3535
"electron-updater": "^6.6.2",
3636
"icojs": "^0.19.5",
3737
"sqlite-better-trigram": "0.0.3",
38-
"sqlite3-fts5-html": "^0.0.3",
38+
"sqlite3-fts5-html": "^0.0.4",
3939
"typed-emitter": "^2.1.0",
4040
"yargs": "^17.7.2",
4141
"zod": "3.24.3"

apps/desktop/patches/better-sqlite3-multiple-ciphers+11.3.0.patch renamed to apps/desktop/patches/better-sqlite3-multiple-ciphers+11.10.0.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/better-sqlite3-multiple-ciphers/deps/defines.gypi b/node_modules/better-sqlite3-multiple-ciphers/deps/defines.gypi
2-
index 1a14ecd..dabcce2 100644
2+
index 1a14ecd..ff938f1 100644
33
--- a/node_modules/better-sqlite3-multiple-ciphers/deps/defines.gypi
44
+++ b/node_modules/better-sqlite3-multiple-ciphers/deps/defines.gypi
55
@@ -38,5 +38,6 @@

apps/desktop/src/api/sqlite-kysely.ts

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class SQLite {
3333
initialized = false;
3434
preparedStatements: Map<string, Statement<unknown[]>> = new Map();
3535
retryCounter: Record<string, number> = {};
36+
extensionsLoaded = false;
37+
3638
constructor() {
3739
console.log("new sqlite worker");
3840
}
@@ -46,10 +48,6 @@ export class SQLite {
4648
this.sqlite = require("better-sqlite3-multiple-ciphers")(
4749
filePath
4850
).unsafeMode(true);
49-
const betterTrigram = require("sqlite-better-trigram");
50-
const fts5Html = require("sqlite3-fts5-html");
51-
betterTrigram.load(this.sqlite);
52-
fts5Html.load(this.sqlite);
5351
}
5452

5553
/**
@@ -117,6 +115,20 @@ export class SQLite {
117115
} catch (e) {
118116
if (e instanceof Error) e.message += ` (query: ${sql})`;
119117
throw e;
118+
} finally {
119+
// Since SQLite 3.48.0 (SQLite3MC v2.0.2) it's not possible to load fts5
120+
// extensions before database has been decrypting. This is because
121+
// executing a `SELECT` now accesses the underlying databases resulting in
122+
// an error. Since FTS5 extensions depend on `SELECT fts5` to load the
123+
// fts5 API, we must wait decrypt the database before we can load
124+
// the extensions.
125+
if (!this.extensionsLoaded && (await this.isDatabaseReady())) {
126+
const betterTrigram = require("sqlite-better-trigram");
127+
const fts5Html = require("sqlite3-fts5-html");
128+
betterTrigram.load(this.sqlite);
129+
fts5Html.load(this.sqlite);
130+
this.extensionsLoaded = true;
131+
}
120132
}
121133
}
122134

@@ -144,4 +156,22 @@ export class SQLite {
144156
retryDelay: 500
145157
});
146158
}
159+
160+
/**
161+
* This just executes `SELECT 1` on the database to make sure its ready.
162+
* On an encrypted database, this will fail until `PRAGMA key` has been
163+
* called.
164+
*/
165+
private async isDatabaseReady() {
166+
// return this.exec(`SELECT 1;`)
167+
// .then(() => true)
168+
// .catch(() => false);
169+
if (!this.sqlite) return false;
170+
try {
171+
this.sqlite.prepare(`SELECT 1;`).run();
172+
return true;
173+
} catch {
174+
return false;
175+
}
176+
}
147177
}

apps/mobile/app/components/auth/change-password.js

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,20 @@ You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20+
import { strings } from "@notesnook/intl";
2021
import React, { useRef, useState } from "react";
2122
import { View } from "react-native";
2223
import { db } from "../../common/database";
23-
import {
24-
eSendEvent,
25-
presentSheet,
26-
ToastManager
27-
} from "../../services/event-manager";
24+
import BackupService from "../../services/backup";
25+
import { eSendEvent, ToastManager } from "../../services/event-manager";
26+
import Navigation from "../../services/navigation";
2827
import { useUserStore } from "../../stores/use-user-store";
29-
import { eCloseSheet, eOpenRecoveryKeyDialog } from "../../utils/events";
30-
import DialogHeader from "../dialog/dialog-header";
28+
import { eOpenRecoveryKeyDialog } from "../../utils/events";
29+
import { DefaultAppStyles } from "../../utils/styles";
30+
import { Dialog } from "../dialog";
3131
import { Button } from "../ui/button";
3232
import Input from "../ui/input";
3333
import { Notice } from "../ui/notice";
34-
import Seperator from "../ui/seperator";
35-
import { Dialog } from "../dialog";
36-
import BackupService from "../../services/backup";
37-
import { sleep } from "../../utils/time";
38-
import { strings } from "@notesnook/intl";
39-
import { DefaultAppStyles } from "../../utils/styles";
4034

4135
export const ChangePassword = () => {
4236
const passwordInputRef = useRef();
@@ -85,8 +79,7 @@ export const ChangePassword = () => {
8579
context: "global"
8680
});
8781
setLoading(false);
88-
eSendEvent(eCloseSheet);
89-
await sleep(300);
82+
Navigation.goBack();
9083
eSendEvent(eOpenRecoveryKeyDialog);
9184
} catch (e) {
9285
setLoading(false);
@@ -108,9 +101,6 @@ export const ChangePassword = () => {
108101
}}
109102
>
110103
<Dialog context="change-password-dialog" />
111-
<DialogHeader title={strings.changePassword()} />
112-
<Seperator />
113-
114104
<Input
115105
fwdRef={oldPasswordInputRef}
116106
onChangeText={(value) => {
@@ -160,9 +150,3 @@ export const ChangePassword = () => {
160150
</View>
161151
);
162152
};
163-
164-
ChangePassword.present = () => {
165-
presentSheet({
166-
component: <ChangePassword />
167-
});
168-
};

apps/mobile/app/components/auth/login.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { hideAuth } from "./common";
3939
import { ForgotPassword } from "./forgot-password";
4040
import { useLogin } from "./use-login";
4141
import { DefaultAppStyles } from "../../utils/styles";
42+
import { Dialog } from "../dialog";
4243

4344
const LoginSteps = {
4445
emailAuth: 1,
@@ -89,7 +90,7 @@ export const Login = ({ changeMode }) => {
8990
return (
9091
<>
9192
<ForgotPassword />
92-
<SheetProvider context="two_factor_verify" />
93+
<Dialog context="two_factor_verify" />
9394
<View
9495
style={{
9596
borderRadius: DDS.isTab ? 5 : 0,

0 commit comments

Comments
 (0)