Merge pull request #3478 from overleaf/jpa-preseve-out-of-sync-trigger

[frontend] preserve the error handler that powers the out-of-sync modal

GitOrigin-RevId: 759ede691658d42cedec7c984b284e45d5c776e9
This commit is contained in:
Brian Gough 2020-12-14 09:21:04 +00:00 committed by Copybot
parent 2200221820
commit 62dd773629

View file

@ -221,6 +221,8 @@ export default (EditorManager = (function() {
// Do not trigger any UI changes from remote operations // Do not trigger any UI changes from remote operations
this._unbindFromDocumentEvents(current_sharejs_doc) this._unbindFromDocumentEvents(current_sharejs_doc)
// Keep listening for out-of-sync and similar errors.
this._attachErrorHandlerToDocument(doc, current_sharejs_doc)
// Teardown the Document -> ShareJsDoc -> sharejs doc // Teardown the Document -> ShareJsDoc -> sharejs doc
// By the time this completes, the Document instance is no longer // By the time this completes, the Document instance is no longer
@ -278,7 +280,7 @@ export default (EditorManager = (function() {
}) })
} }
_bindToDocumentEvents(doc, sharejs_doc) { _attachErrorHandlerToDocument(doc, sharejs_doc) {
sharejs_doc.on('error', (error, meta, editorContent) => { sharejs_doc.on('error', (error, meta, editorContent) => {
let message let message
if ((error != null ? error.message : undefined) != null) { if ((error != null ? error.message : undefined) != null) {
@ -314,6 +316,10 @@ export default (EditorManager = (function() {
removeHandler() removeHandler()
}) })
}) })
}
_bindToDocumentEvents(doc, sharejs_doc) {
this._attachErrorHandlerToDocument(doc, sharejs_doc)
return sharejs_doc.on('externalUpdate', update => { return sharejs_doc.on('externalUpdate', update => {
if (this._ignoreExternalUpdates) { if (this._ignoreExternalUpdates) {