mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-30 05:55:30 -05: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 = () =>
|
||||
@tryReconnect()
|
||||
|
||||
@$scope.$on "editor:change", () =>
|
||||
@lastUpdated = new Date()
|
||||
|
||||
@ide.socket = io.connect null,
|
||||
reconnect: false
|
||||
"force new connection": true
|
||||
|
@ -70,10 +73,8 @@ define [], () ->
|
|||
@ide.socket.disconnect()
|
||||
|
||||
startAutoReconnectCountdown: () ->
|
||||
lastUpdated = @ide.editorManager.lastUpdated()
|
||||
|
||||
twoMinutes = 2 * 60 * 1000
|
||||
if lastUpdated? and new Date() - lastUpdated > twoMinutes
|
||||
if @lastUpdated? and new Date() - @lastUpdated > twoMinutes
|
||||
# between 1 minute and 3 minutes
|
||||
countdown = 60 + Math.floor(Math.random() * 120)
|
||||
else
|
||||
|
|
|
@ -7,10 +7,8 @@ define [
|
|||
constructor: (@ide, @$scope) ->
|
||||
@$scope.editor = {
|
||||
sharejs_doc: null
|
||||
last_updated: null
|
||||
open_doc_id: null
|
||||
opening: true
|
||||
cursorPosition: {}
|
||||
gotoLine: null
|
||||
}
|
||||
|
||||
|
@ -93,9 +91,6 @@ define [
|
|||
_unbindFromDocumentEvents: (document) ->
|
||||
document.off()
|
||||
|
||||
lastUpdated: () ->
|
||||
@$scope.editor.last_updated
|
||||
|
||||
getCurrentDocValue: () ->
|
||||
@$scope.editor.sharejs_doc?.getSnapshot()
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@ define [
|
|||
fontSize: "="
|
||||
autoComplete: "="
|
||||
sharejsDoc: "="
|
||||
lastUpdated: "="
|
||||
spellCheckLanguage: "="
|
||||
cursorPosition: "="
|
||||
highlights: "="
|
||||
text: "="
|
||||
readOnly: "="
|
||||
|
@ -117,8 +115,7 @@ define [
|
|||
|
||||
doc = session.getDocument()
|
||||
doc.on "change", () ->
|
||||
scope.$apply () ->
|
||||
scope.lastUpdated = new Date()
|
||||
scope.$emit "#{scope.name}:change"
|
||||
|
||||
sharejs_doc.on "remoteop.recordForUndo", () =>
|
||||
undoManager.nextUpdateIsRemote = true
|
||||
|
|
Loading…
Reference in a new issue