mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
feat: add db migration progress dialog
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import { EventSourcePolyfill as EventSource } from "event-source-polyfill";
|
import { EventSourcePolyfill as EventSource } from "event-source-polyfill";
|
||||||
|
import { EVENTS } from "notes-core/common";
|
||||||
|
import { TaskManager } from "./task-manager";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {import("notes-core/api").default}
|
* @type {import("notes-core/api").default}
|
||||||
@@ -11,27 +13,42 @@ async function initializeDatabase(persistence) {
|
|||||||
db = new Database(new NNStorage(persistence), EventSource, FS);
|
db = new Database(new NNStorage(persistence), EventSource, FS);
|
||||||
|
|
||||||
// if (isTesting()) {
|
// if (isTesting()) {
|
||||||
// db.host({
|
db.host({
|
||||||
// API_HOST: "https://api.notesnook.com",
|
API_HOST: "https://api.notesnook.com",
|
||||||
// AUTH_HOST: "https://auth.streetwriters.co",
|
AUTH_HOST: "https://auth.streetwriters.co",
|
||||||
// SSE_HOST: "https://events.streetwriters.co",
|
SSE_HOST: "https://events.streetwriters.co",
|
||||||
// });
|
});
|
||||||
// } else {
|
// } else {
|
||||||
// db.host({
|
// db.host({
|
||||||
// API_HOST: "http://localhost:5264",
|
// API_HOST: "http://localhost:5264",
|
||||||
// AUTH_HOST: "http://localhost:8264",
|
// AUTH_HOST: "http://localhost:8264",
|
||||||
// SSE_HOST: "http://localhost:7264",
|
// SSE_HOST: "http://localhost:7264",
|
||||||
// });
|
// });
|
||||||
const base = `http://${process.env.REACT_APP_LOCALHOST}`;
|
// const base = `http://${process.env.REACT_APP_LOCALHOST}`;
|
||||||
db.host({
|
// db.host({
|
||||||
API_HOST: `${base}:5264`,
|
// API_HOST: `${base}:5264`,
|
||||||
AUTH_HOST: `${base}:8264`,
|
// AUTH_HOST: `${base}:8264`,
|
||||||
SSE_HOST: `${base}:7264`,
|
// SSE_HOST: `${base}:7264`,
|
||||||
ISSUES_HOST: `${base}:2624`,
|
// ISSUES_HOST: `${base}:2624`,
|
||||||
SUBSCRIPTIONS_HOST: `${base}:9264`,
|
// SUBSCRIPTIONS_HOST: `${base}:9264`,
|
||||||
});
|
// });
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
db.eventManager.subscribe(EVENTS.databaseMigrating, async ({ from, to }) => {
|
||||||
|
await TaskManager.startTask({
|
||||||
|
type: "modal",
|
||||||
|
title: `Migrating your database`,
|
||||||
|
subtitle:
|
||||||
|
"Please do not close your browser/app before the migration is done.",
|
||||||
|
action: (task) => {
|
||||||
|
task({ text: `Migrating database from v${from} to v${to}` });
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
db.eventManager.subscribe(EVENTS.databaseMigrated, resolve);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
await db.init();
|
await db.init();
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user