Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: remove monographs on logout

thecodrr73212bee0f46
diff --git a/packages/core/api/index.js b/packages/core/api/index.js
index 3645a7ebe..1a6ba535a 100644
--- a/packages/core/api/index.js
+++ b/packages/core/api/index.js
@@ -49,7 +49,8 @@ class Database {
[EVENTS.userLoggedIn, EVENTS.userFetched],
this.connectSSE.bind(this)
);
- EV.subscribe(EVENTS.userLoggedOut, () => {
+ EV.subscribe(EVENTS.userLoggedOut, async () => {
+ await this.monographs.deinit();
clearTimeout(this._syncTimeout);
if (this.evtSource) {
this.evtSource.close();
diff --git a/packages/core/api/monographs.js b/packages/core/api/monographs.js
index 85b448004..26d996c16 100644
--- a/packages/core/api/monographs.js
+++ b/packages/core/api/monographs.js
@@ -11,6 +11,11 @@ class Monographs {
this.monographs = [];
}
+ async deinit() {
+ this.monographs = [];
+ await this._db.context.write("monographs", this.monographs);
+ }
+
async init() {
const user = await this._db.user.getUser();
const token = await this._db.user.tokenManager.getAccessToken();