Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
sending ws messages doesn't need await
zadam5e3538669d60
diff --git a/src/services/content_hash.js b/src/services/content_hash.jsindex 0571acb824..d9f5e50736 100644--- a/src/services/content_hash.js+++ b/src/services/content_hash.js@@ -57,7 +57,7 @@ async function checkContentHashes(otherHashes) {if (key !== 'recent_notes') {// let's not get alarmed about recent notes which get updated often and can cause failures in race conditions- await ws.sendMessageToAllClients({type: 'sync-hash-check-failed'});+ ws.sendMessageToAllClients({type: 'sync-hash-check-failed'});}}}diff --git a/src/services/task_context.js b/src/services/task_context.jsindex 3dd4d7cfb0..4731fed446 100644--- a/src/services/task_context.js+++ b/src/services/task_context.js@@ -25,13 +25,13 @@ class TaskContext {return taskContexts[taskId];}- async increaseProgressCount() {+ increaseProgressCount() {this.progressCount++;if (Date.now() - this.lastSentCountTs >= 300) {this.lastSentCountTs = Date.now();- await ws.sendMessageToAllClients({+ ws.sendMessageToAllClients({type: 'task-progress-count',taskId: this.taskId,taskType: this.taskType,@@ -41,8 +41,8 @@ class TaskContext {}}- async reportError(message) {- await ws.sendMessageToAllClients({+ reportError(message) {+ ws.sendMessageToAllClients({type: 'task-error',taskId: this.taskId,taskType: this.taskType,@@ -51,8 +51,8 @@ class TaskContext {});}- async taskSucceeded(result) {- await ws.sendMessageToAllClients({+ taskSucceeded(result) {+ ws.sendMessageToAllClients({type: 'task-succeeded',taskId: this.taskId,taskType: this.taskType,diff --git a/src/services/ws.js b/src/services/ws.jsindex 41089d23c8..1ac0d88541 100644--- a/src/services/ws.js+++ b/src/services/ws.js@@ -45,7 +45,7 @@ function init(httpServer, sessionParser) {});}-async function sendMessage(client, message) {+function sendMessage(client, message) {const jsonStr = JSON.stringify(message);if (client.readyState === WebSocket.OPEN) {@@ -53,7 +53,7 @@ async function sendMessage(client, message) {}}-async function sendMessageToAllClients(message) {+function sendMessageToAllClients(message) {const jsonStr = JSON.stringify(message);if (webSocketServer) {@@ -88,23 +88,23 @@ async function sendPing(client, lastSentSyncId) {const stats = require('./sync').stats;- await sendMessage(client, {+ sendMessage(client, {type: 'sync',data: syncData,outstandingSyncs: stats.outstandingPushes + stats.outstandingPulls});}-async function refreshTree() {- await sendMessageToAllClients({ type: 'refresh-tree' });+function refreshTree() {+ sendMessageToAllClients({ type: 'refresh-tree' });}-async function syncPullInProgress() {- await sendMessageToAllClients({ type: 'sync-pull-in-progress' });+function syncPullInProgress() {+ sendMessageToAllClients({ type: 'sync-pull-in-progress' });}async function syncPullFinished() {- await sendMessageToAllClients({ type: 'sync-pull-finished' });+ sendMessageToAllClients({ type: 'sync-pull-finished' });}module.exports = {