From 3a9832a8c6467f292127f9f2faea18442e8c1826 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 21 Nov 2019 17:56:04 +0000 Subject: [PATCH] Fix ringing chirp on loading We have a heap of logic to do the right thing when a call event arrives, eg. wait until the client is ready so we can see if there's already been a hangup event before saying there's an incoming call. Unfortunately it only waited until the client was prepared, not until it was syncing, so any events that arrived from the server in the catchup sync bypassed this logic altogether. This was probably broken back when we introduced the sync accumulator, since before then, "PREPARED" meant, "done initialsync" rather than "loaded fake initialsync from storage". Fixes https://github.com/vector-im/riot-web/issues/3572 --- src/client.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/client.js b/src/client.js index 8af841c99..8f2dec601 100644 --- a/src/client.js +++ b/src/client.js @@ -4640,10 +4640,12 @@ function setupCallEventHandler(client) { // notifications. It needs to be buffered to correctly determine if an // incoming call has had a matching answer/hangup. let callEventBuffer = []; - let isClientPrepared = false; - client.on("sync", function(state) { - if (state === "PREPARED") { - isClientPrepared = true; + let isClientSyncing = false; + const onSync = function(state) { + if (state === "SYNCING") { + isClientSyncing = true; + client.removeListener("sync", onSync); + const ignoreCallIds = {}; // Set // inspect the buffer and mark all calls which have been answered // or hung up before passing them to the call event handler. @@ -4664,7 +4666,8 @@ function setupCallEventHandler(client) { }); callEventBuffer = []; } - }); + }; + client.on("sync", onSync); client.on("event", onEvent); @@ -4677,7 +4680,7 @@ function setupCallEventHandler(client) { } return; } - if (!isClientPrepared) { + if (!isClientSyncing) { callEventBuffer.push(event); return; }