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

Merge pull request #3483 from overleaf/jpa-leave-on-out-of-sync

[frontend] displaying the out-of-sync modal is a dead end

GitOrigin-RevId: 475bf851c9f07bb2a7b052879b98756881de44a2
Brian Gough 5 лет назад
Родитель
Сommit
ad8f7fbb5d

+ 18 - 3
services/web/frontend/js/ide/editor/EditorManager.js

@@ -302,15 +302,30 @@ export default (EditorManager = (function() {
             'Sorry, this file has too many comments or tracked changes. Please try accepting or rejecting some existing changes, or resolving and deleting some comments.'
             'Sorry, this file has too many comments or tracked changes. Please try accepting or rejecting some existing changes, or resolving and deleting some comments.'
           )
           )
         } else {
         } else {
+          // Do not allow this doc to open another error modal.
+          sharejs_doc.off('error')
+
+          // Preserve the sharejs contents before the teardown.
+          editorContent =
+            typeof editorContent === 'string'
+              ? editorContent
+              : sharejs_doc.doc._doc.snapshot
+
+          // Tear down the ShareJsDoc.
+          if (sharejs_doc.doc) sharejs_doc.doc.clearInflightAndPendingOps()
+
+          // Do not re-join after re-connecting.
+          sharejs_doc.leaveAndCleanUp()
+
           this.ide.socket.disconnect()
           this.ide.socket.disconnect()
           this.ide.reportError(error, meta)
           this.ide.reportError(error, meta)
           this.ide.showOutOfSyncModal(
           this.ide.showOutOfSyncModal(
             'Out of sync',
             'Out of sync',
             "Sorry, this file has gone out of sync and we need to do a full refresh. <br> <a href='/learn/Kb/Editor_out_of_sync_problems'>Please see this help guide for more information</a>",
             "Sorry, this file has gone out of sync and we need to do a full refresh. <br> <a href='/learn/Kb/Editor_out_of_sync_problems'>Please see this help guide for more information</a>",
-            typeof editorContent === 'string'
-              ? editorContent
-              : sharejs_doc.doc._doc.snapshot
+            editorContent
           )
           )
+          // Do not forceReopen the document.
+          return
         }
         }
         const removeHandler = this.$scope.$on('project:joined', () => {
         const removeHandler = this.$scope.$on('project:joined', () => {
           this.openDoc(doc, { forceReopen: true })
           this.openDoc(doc, { forceReopen: true })

+ 1 - 0
services/web/frontend/js/ide/editor/ShareJsDoc.js

@@ -270,6 +270,7 @@ export default (ShareJsDoc = (function() {
     }
     }
 
 
     clearInflightAndPendingOps() {
     clearInflightAndPendingOps() {
+      this._clearFatalTimeoutTimer()
       this._doc.inflightOp = null
       this._doc.inflightOp = null
       this._doc.inflightCallbacks = []
       this._doc.inflightCallbacks = []
       this._doc.pendingOp = null
       this._doc.pendingOp = null