From 8c65fbb996ea9df8f920bcc29ba7bf8fafc30e63 Mon Sep 17 00:00:00 2001 From: thecodrr Date: Thu, 14 Apr 2022 01:10:25 +0500 Subject: [PATCH] fix: request sync before sse connects (fixes streetwriters/notesnook#465) --- packages/core/api/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/api/index.js b/packages/core/api/index.js index b4a81e7cf..8d4066d86 100644 --- a/packages/core/api/index.js +++ b/packages/core/api/index.js @@ -146,6 +146,7 @@ class Database { async connectSSE(args) { await this.sseMutex.runExclusive(async () => { if (args && !!args.error) return; + this.eventManager.publish(EVENTS.databaseSyncRequested, true, false); const forceReconnect = args && args.force; if ( @@ -164,7 +165,6 @@ class Database { this.evtSource.onopen = async () => { console.log("SSE: opened channel successfully!"); - this.eventManager.publish(EVENTS.databaseSyncRequested, true, false); }; this.evtSource.onerror = function (error) {