mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 13:53:40 -05:00
Merge pull request #3337 from overleaf/jpa-fix-consitency-check
[frontend] Document: fix consistency check GitOrigin-RevId: d303fe48e4f3460dab609d53e195992920af7b1b
This commit is contained in:
parent
57e9cf2829
commit
fc1816b0fc
2 changed files with 23 additions and 22 deletions
|
@ -1,4 +1,3 @@
|
|||
import _ from 'lodash'
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
handle-callback-err,
|
||||
|
@ -84,8 +83,8 @@ export default (Document = (function() {
|
|||
this.connected = this.ide.socket.socket.connected
|
||||
this.joined = false
|
||||
this.wantToBeJoined = false
|
||||
this._checkAceConsistency = _.bind(this._checkConsistency, this, this.ace)
|
||||
this._checkCMConsistency = _.bind(this._checkConsistency, this, this.cm)
|
||||
this._checkAceConsistency = () => this._checkConsistency(this.ace)
|
||||
this._checkCMConsistency = () => this._checkConsistency(this.cm)
|
||||
this._bindToEditorEvents()
|
||||
this._bindToSocketEvents()
|
||||
}
|
||||
|
@ -140,7 +139,6 @@ export default (Document = (function() {
|
|||
}
|
||||
|
||||
_checkConsistency(editor) {
|
||||
return () => {
|
||||
// We've been seeing a lot of errors when I think there shouldn't be
|
||||
// any, which may be related to this check happening before the change is
|
||||
// applied. If we use a timeout, hopefully we can reduce this.
|
||||
|
@ -150,12 +148,13 @@ export default (Document = (function() {
|
|||
this.doc != null ? this.doc.getSnapshot() : undefined
|
||||
if (editorValue !== sharejsValue) {
|
||||
return this._onError(
|
||||
new Error('Editor text does not match server text')
|
||||
new Error('Editor text does not match server text'),
|
||||
{},
|
||||
editorValue
|
||||
)
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
}
|
||||
|
||||
getSnapshot() {
|
||||
return this.doc != null ? this.doc.getSnapshot() : undefined
|
||||
|
@ -653,7 +652,7 @@ export default (Document = (function() {
|
|||
})
|
||||
}
|
||||
|
||||
_onError(error, meta) {
|
||||
_onError(error, meta, editorContent) {
|
||||
if (meta == null) {
|
||||
meta = {}
|
||||
}
|
||||
|
@ -682,7 +681,7 @@ export default (Document = (function() {
|
|||
if (this.doc != null) {
|
||||
this.doc.clearInflightAndPendingOps()
|
||||
}
|
||||
this.trigger('error', error, meta)
|
||||
this.trigger('error', error, meta, editorContent)
|
||||
// The clean up should run after the error is triggered because the error triggers a
|
||||
// disconnect. If we run the clean up first, we remove our event handlers and miss
|
||||
// the disconnect event, which means we try to leaveDoc when the connection comes back.
|
||||
|
|
|
@ -246,7 +246,7 @@ export default (EditorManager = (function() {
|
|||
}
|
||||
|
||||
_bindToDocumentEvents(doc, sharejs_doc) {
|
||||
sharejs_doc.on('error', (error, meta) => {
|
||||
sharejs_doc.on('error', (error, meta, editorContent) => {
|
||||
let message
|
||||
if ((error != null ? error.message : undefined) != null) {
|
||||
;({ message } = error)
|
||||
|
@ -271,7 +271,9 @@ export default (EditorManager = (function() {
|
|||
this.ide.showOutOfSyncModal(
|
||||
'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>",
|
||||
sharejs_doc.doc._doc.snapshot
|
||||
typeof editorContent === 'string'
|
||||
? editorContent
|
||||
: sharejs_doc.doc._doc.snapshot
|
||||
)
|
||||
}
|
||||
const removeHandler = this.$scope.$on('project:joined', () => {
|
||||
|
|
Loading…
Reference in a new issue