Merge pull request #3479 from overleaf/jpa-ignore-error-of-other-doc

[frontend] do not process otUpdateError of other docs

GitOrigin-RevId: 95b43fbe1f24c1b60a0b9beeb3814645231e5063
This commit is contained in:
Brian Gough
2020-12-14 09:28:36 +00:00
committed by Copybot
parent 62dd773629
commit a393352516
@@ -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)