diff options
Diffstat (limited to '')
-rw-r--r-- | lib/realtime.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/realtime.js b/lib/realtime.js index def8f217..c1db6886 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -354,9 +354,12 @@ function clearSocketQueue(queue, socket) { } function connectNextSocket() { - isConnectionBusy = false; - if (connectionSocketQueue.length > 0) - startConnection(connectionSocketQueue[0]); + setTimeout(function () { + isConnectionBusy = false; + if (connectionSocketQueue.length > 0) { + startConnection(connectionSocketQueue[0]); + } + }, 1); } function interruptConnection(socket, note, user) { @@ -693,8 +696,11 @@ function operationCallback(socket, operation) { } note.tempUsers[userId] = Date.now(); } - // save authorship - note.authorship = models.Note.updateAuthorshipByOperation(operation, userId, note.authorship); + // save authorship - use timer here because it's an O(n) complexity algorithm + setImmediate(function () { + note.authorship = models.Note.updateAuthorshipByOperation(operation, userId, note.authorship); + }); +} function updateHistory(userId, note, time) { var noteId = note.alias ? note.alias : LZString.compressToBase64(note.id); |