mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 14:03:36 +08:00
sending ws messages doesn't need await
This commit is contained in:
parent
23c449ca0c
commit
5e3538669d
3 changed files with 15 additions and 15 deletions
|
@ -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'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue