Просмотр исходного кода

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

[frontend] do not process otUpdateError of other docs

GitOrigin-RevId: 95b43fbe1f24c1b60a0b9beeb3814645231e5063
Brian Gough 5 лет назад
Родитель
Сommit
a393352516
1 измененных файлов с 10 добавлено и 1 удалено
  1. 10 1
      services/web/frontend/js/ide/editor/Document.js

+ 10 - 1
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)