From a3933525165eb35a758be645e76aba11bcc041b7 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 14 Dec 2020 09:28:36 +0000 Subject: [PATCH] Merge pull request #3479 from overleaf/jpa-ignore-error-of-other-doc [frontend] do not process otUpdateError of other docs GitOrigin-RevId: 95b43fbe1f24c1b60a0b9beeb3814645231e5063 --- services/web/frontend/js/ide/editor/Document.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/ide/editor/Document.js b/services/web/frontend/js/ide/editor/Document.js index 4e9ff2046e..7fa840ec5a 100644 --- a/services/web/frontend/js/ide/editor/Document.js +++ b/services/web/frontend/js/ide/editor/Document.js @@ -199,7 +199,16 @@ export default (Document = (function() { _bindToSocketEvents() { this._onUpdateAppliedHandler = update => this._onUpdateApplied(update) this.ide.socket.on('otUpdateApplied', this._onUpdateAppliedHandler) - this._onErrorHandler = (error, update) => this._onError(error, update) + this._onErrorHandler = (error, message) => { + // 'otUpdateError' are emitted per doc socket.io room, hence we can be + // sure that message.doc_id exists. + if (message.doc_id !== this.doc_id) { + // This error is for another doc. Do not action it. We could open + // a modal that has the wrong context on it. + return + } + this._onError(error, message) + } this.ide.socket.on('otUpdateError', this._onErrorHandler) this._onDisconnectHandler = error => this._onDisconnect(error) return this.ide.socket.on('disconnect', this._onDisconnectHandler)