A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: register fts5 extensions after db decryption
Abdullah Attae6a5b85011f2
diff --git a/apps/web/src/common/sqlite/sqlite-api.js b/apps/web/src/common/sqlite/sqlite-api.jsindex 4387c99cc..6ab1736af 100644--- a/apps/web/src/common/sqlite/sqlite-api.js+++ b/apps/web/src/common/sqlite/sqlite-api.js@@ -561,11 +561,16 @@ export function Factory(Module) {databases.add(db);Module._sqlite3_free(zVfs);+ check(fname, result);+ return db;+ };+ })();++ sqlite3.register_extensions = (function () {+ return async function (db) {Module.ccall("RegisterExtensionFunctions", "void", ["number"], [db]);Module.ccall("sqlite3Fts5BetterTrigramInit", "void", ["number"], [db]);Module.ccall("sqlite3Fts5HtmlInit", "void", ["number"], [db]);- check(fname, result);- return db;};})();diff --git a/apps/web/src/common/sqlite/sqlite-types.ts b/apps/web/src/common/sqlite/sqlite-types.tsindex c029e3fb4..093ce949a 100644--- a/apps/web/src/common/sqlite/sqlite-types.ts+++ b/apps/web/src/common/sqlite/sqlite-types.ts@@ -724,6 +724,12 @@ export interface SQLiteAPI {*/open_v2(zFilename: string, iFlags?: number, zVfs?: string): Promise<number>;+ /**+ * Register and init extensions.+ * @param db database pointer+ */+ register_extensions(db: number): Promise<void>;+/*** Compile an SQL statement*diff --git a/apps/web/src/common/sqlite/sqlite.worker.ts b/apps/web/src/common/sqlite/sqlite.worker.tsindex 5ca3fd7e5..36929cf03 100644--- a/apps/web/src/common/sqlite/sqlite.worker.ts+++ b/apps/web/src/common/sqlite/sqlite.worker.ts@@ -227,6 +227,9 @@ class _SQLiteWorker {}async initialize() {+ if (typeof this.db === "number")+ await this.sqlite.register_extensions(this.db);+self.dispatchEvent(new MessageEvent("message", {data: { type: "databaseInitialized", dbName: this.name }