mirror of
https://github.com/overleaf/overleaf.git
synced 2025-02-18 18:52:03 +00:00
Don't do a scope.apply on every change
This commit is contained in:
parent
558d32adeb
commit
f2b8a5971f
3 changed files with 5 additions and 12 deletions
|
@ -11,6 +11,9 @@ define [], () ->
|
||||||
@$scope.tryReconnectNow = () =>
|
@$scope.tryReconnectNow = () =>
|
||||||
@tryReconnect()
|
@tryReconnect()
|
||||||
|
|
||||||
|
@$scope.$on "editor:change", () =>
|
||||||
|
@lastUpdated = new Date()
|
||||||
|
|
||||||
@ide.socket = io.connect null,
|
@ide.socket = io.connect null,
|
||||||
reconnect: false
|
reconnect: false
|
||||||
"force new connection": true
|
"force new connection": true
|
||||||
|
@ -70,10 +73,8 @@ define [], () ->
|
||||||
@ide.socket.disconnect()
|
@ide.socket.disconnect()
|
||||||
|
|
||||||
startAutoReconnectCountdown: () ->
|
startAutoReconnectCountdown: () ->
|
||||||
lastUpdated = @ide.editorManager.lastUpdated()
|
|
||||||
|
|
||||||
twoMinutes = 2 * 60 * 1000
|
twoMinutes = 2 * 60 * 1000
|
||||||
if lastUpdated? and new Date() - lastUpdated > twoMinutes
|
if @lastUpdated? and new Date() - @lastUpdated > twoMinutes
|
||||||
# between 1 minute and 3 minutes
|
# between 1 minute and 3 minutes
|
||||||
countdown = 60 + Math.floor(Math.random() * 120)
|
countdown = 60 + Math.floor(Math.random() * 120)
|
||||||
else
|
else
|
||||||
|
|
|
@ -7,10 +7,8 @@ define [
|
||||||
constructor: (@ide, @$scope) ->
|
constructor: (@ide, @$scope) ->
|
||||||
@$scope.editor = {
|
@$scope.editor = {
|
||||||
sharejs_doc: null
|
sharejs_doc: null
|
||||||
last_updated: null
|
|
||||||
open_doc_id: null
|
open_doc_id: null
|
||||||
opening: true
|
opening: true
|
||||||
cursorPosition: {}
|
|
||||||
gotoLine: null
|
gotoLine: null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,9 +91,6 @@ define [
|
||||||
_unbindFromDocumentEvents: (document) ->
|
_unbindFromDocumentEvents: (document) ->
|
||||||
document.off()
|
document.off()
|
||||||
|
|
||||||
lastUpdated: () ->
|
|
||||||
@$scope.editor.last_updated
|
|
||||||
|
|
||||||
getCurrentDocValue: () ->
|
getCurrentDocValue: () ->
|
||||||
@$scope.editor.sharejs_doc?.getSnapshot()
|
@$scope.editor.sharejs_doc?.getSnapshot()
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,7 @@ define [
|
||||||
fontSize: "="
|
fontSize: "="
|
||||||
autoComplete: "="
|
autoComplete: "="
|
||||||
sharejsDoc: "="
|
sharejsDoc: "="
|
||||||
lastUpdated: "="
|
|
||||||
spellCheckLanguage: "="
|
spellCheckLanguage: "="
|
||||||
cursorPosition: "="
|
|
||||||
highlights: "="
|
highlights: "="
|
||||||
text: "="
|
text: "="
|
||||||
readOnly: "="
|
readOnly: "="
|
||||||
|
@ -117,8 +115,7 @@ define [
|
||||||
|
|
||||||
doc = session.getDocument()
|
doc = session.getDocument()
|
||||||
doc.on "change", () ->
|
doc.on "change", () ->
|
||||||
scope.$apply () ->
|
scope.$emit "#{scope.name}:change"
|
||||||
scope.lastUpdated = new Date()
|
|
||||||
|
|
||||||
sharejs_doc.on "remoteop.recordForUndo", () =>
|
sharejs_doc.on "remoteop.recordForUndo", () =>
|
||||||
undoManager.nextUpdateIsRemote = true
|
undoManager.nextUpdateIsRemote = true
|
||||||
|
|
Loading…
Reference in a new issue