mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #3511 from overleaf/jpa-false-positive-change-events
[frontend] EditorWatchdogManager: ignore false-positive change events GitOrigin-RevId: 539cb6befce7210ed606c1e62045c9d15ce5b911
This commit is contained in:
parent
ae511474f2
commit
846f2379a8
2 changed files with 13 additions and 1 deletions
|
@ -183,6 +183,11 @@ export default class EditorWatchdogManager {
|
|||
onChange = (editor, change) => {
|
||||
// Ignore remote changes.
|
||||
if (change.origin === 'remote') return
|
||||
|
||||
// sharejs only looks at DEL or INSERT change events.
|
||||
// NOTE: Keep in sync with sharejs.
|
||||
if (!(change.removed || change.text)) return
|
||||
|
||||
this.onEdit()
|
||||
}
|
||||
} else {
|
||||
|
@ -190,6 +195,11 @@ export default class EditorWatchdogManager {
|
|||
onChange = change => {
|
||||
// Ignore remote changes.
|
||||
if (change.origin === 'remote') return
|
||||
|
||||
// sharejs only looks at DEL or INSERT change events.
|
||||
// NOTE: Keep in sync with sharejs.
|
||||
if (!(change.action === 'remove' || change.action === 'insert')) return
|
||||
|
||||
this.onEdit()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1290,7 +1290,7 @@ define(['ace/ace','crypto-js/sha1'], function (_ignore, CryptoJSSHA1) {
|
|||
var age = this.__lastSubmitTimestamp && (now - this.__lastSubmitTimestamp)
|
||||
var RECOMPUTE_HASH_INTERVAL = 5000
|
||||
// check the document hash regularly (but not if we have checked in the last 5 seconds)
|
||||
var needToRecomputeHash = !this.__lastSubmitTimestamp || (age > RECOMPUTE_HASH_INTERVAL) || (age < 0)
|
||||
var needToRecomputeHash = !this.__lastSubmitTimestamp || (age > RECOMPUTE_HASH_INTERVAL) || (age < 0)
|
||||
if (needToRecomputeHash || window.sl_debugging) {
|
||||
// send git hash of current snapshot
|
||||
var sha1 = CryptoJSSHA1("blob " + this.snapshot.length + "\x00" + this.snapshot).toString()
|
||||
|
@ -1449,6 +1449,7 @@ define(['ace/ace','crypto-js/sha1'], function (_ignore, CryptoJSSHA1) {
|
|||
|
||||
var pos = getStartOffsetPosition(delta.start);
|
||||
|
||||
// NOTE: Keep in sync with EditorWatchdogManager.
|
||||
switch (delta.action) {
|
||||
case 'insert':
|
||||
text = delta.lines.join('\n');
|
||||
|
@ -1611,6 +1612,7 @@ define(['ace/ace','crypto-js/sha1'], function (_ignore, CryptoJSSHA1) {
|
|||
}
|
||||
startPos += delta.from.ch;
|
||||
|
||||
// NOTE: Keep in sync with EditorWatchdogManager.
|
||||
if (delta.removed) {
|
||||
doc.del(startPos, delta.removed.join('\n').length, fromUndo);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue