mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
sending ws messages doesn't need await
This commit is contained in:
parent
23c449ca0c
commit
5e3538669d
@ -57,7 +57,7 @@ async function checkContentHashes(otherHashes) {
|
|||||||
|
|
||||||
if (key !== 'recent_notes') {
|
if (key !== 'recent_notes') {
|
||||||
// let's not get alarmed about recent notes which get updated often and can cause failures in race conditions
|
// 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];
|
return taskContexts[taskId];
|
||||||
}
|
}
|
||||||
|
|
||||||
async increaseProgressCount() {
|
increaseProgressCount() {
|
||||||
this.progressCount++;
|
this.progressCount++;
|
||||||
|
|
||||||
if (Date.now() - this.lastSentCountTs >= 300) {
|
if (Date.now() - this.lastSentCountTs >= 300) {
|
||||||
this.lastSentCountTs = Date.now();
|
this.lastSentCountTs = Date.now();
|
||||||
|
|
||||||
await ws.sendMessageToAllClients({
|
ws.sendMessageToAllClients({
|
||||||
type: 'task-progress-count',
|
type: 'task-progress-count',
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
taskType: this.taskType,
|
taskType: this.taskType,
|
||||||
@ -41,8 +41,8 @@ class TaskContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async reportError(message) {
|
reportError(message) {
|
||||||
await ws.sendMessageToAllClients({
|
ws.sendMessageToAllClients({
|
||||||
type: 'task-error',
|
type: 'task-error',
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
taskType: this.taskType,
|
taskType: this.taskType,
|
||||||
@ -51,8 +51,8 @@ class TaskContext {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async taskSucceeded(result) {
|
taskSucceeded(result) {
|
||||||
await ws.sendMessageToAllClients({
|
ws.sendMessageToAllClients({
|
||||||
type: 'task-succeeded',
|
type: 'task-succeeded',
|
||||||
taskId: this.taskId,
|
taskId: this.taskId,
|
||||||
taskType: this.taskType,
|
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);
|
const jsonStr = JSON.stringify(message);
|
||||||
|
|
||||||
if (client.readyState === WebSocket.OPEN) {
|
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);
|
const jsonStr = JSON.stringify(message);
|
||||||
|
|
||||||
if (webSocketServer) {
|
if (webSocketServer) {
|
||||||
@ -88,23 +88,23 @@ async function sendPing(client, lastSentSyncId) {
|
|||||||
|
|
||||||
const stats = require('./sync').stats;
|
const stats = require('./sync').stats;
|
||||||
|
|
||||||
await sendMessage(client, {
|
sendMessage(client, {
|
||||||
type: 'sync',
|
type: 'sync',
|
||||||
data: syncData,
|
data: syncData,
|
||||||
outstandingSyncs: stats.outstandingPushes + stats.outstandingPulls
|
outstandingSyncs: stats.outstandingPushes + stats.outstandingPulls
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refreshTree() {
|
function refreshTree() {
|
||||||
await sendMessageToAllClients({ type: 'refresh-tree' });
|
sendMessageToAllClients({ type: 'refresh-tree' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncPullInProgress() {
|
function syncPullInProgress() {
|
||||||
await sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
sendMessageToAllClients({ type: 'sync-pull-in-progress' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async function syncPullFinished() {
|
async function syncPullFinished() {
|
||||||
await sendMessageToAllClients({ type: 'sync-pull-finished' });
|
sendMessageToAllClients({ type: 'sync-pull-finished' });
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user