mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Improve reconnection and loading display and logic
This commit is contained in:
parent
7104f458f7
commit
71ca8f63ed
3 changed files with 33 additions and 22 deletions
|
@ -54,9 +54,12 @@ block content
|
|||
include ./editor/file-tree
|
||||
|
||||
.ui-layout-center
|
||||
.loading(ng-show="!editor.sharejs_doc || editor.opening")
|
||||
i.fa.fa-spin.fa-refresh
|
||||
| Loading...
|
||||
#editor(
|
||||
ace-editor,
|
||||
ng-show="!!editor.sharejs_doc"
|
||||
ng-show="!!editor.sharejs_doc && !editor.opening"
|
||||
theme="'cobalt'",
|
||||
show-print-margin="false",
|
||||
sharejs-doc="editor.sharejs_doc",
|
||||
|
|
|
@ -91,6 +91,7 @@ define [], () ->
|
|||
|
||||
decreaseCountdown: () ->
|
||||
console.log "Decreasing countdown"
|
||||
return if !@$scope.connection.reconnection_countdown?
|
||||
@$scope.$apply () =>
|
||||
@$scope.connection.reconnection_countdown--
|
||||
|
||||
|
@ -106,5 +107,5 @@ define [], () ->
|
|||
@$scope.connection.reconnecting = true
|
||||
delete @$scope.connection.reconnection_countdown
|
||||
@ide.socket.socket.reconnect()
|
||||
setTimeout (=> @startAutoReconnectCountdown() if !@connected), 1000
|
||||
setTimeout (=> @startAutoReconnectCountdown() if !@connected), 2000
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ define [
|
|||
@$scope.editor = {
|
||||
sharejs_doc: null
|
||||
last_updated: null
|
||||
open_doc_id: null
|
||||
opening: true
|
||||
}
|
||||
|
||||
@$scope.$on "entity:selected", (event, entity) =>
|
||||
|
@ -30,19 +32,22 @@ define [
|
|||
|
||||
openDoc: (doc, options = {}) ->
|
||||
console.log "Trying to open doc", doc.id
|
||||
return if doc.id == @open_doc_id
|
||||
@open_doc_id = doc.id
|
||||
return if doc.id == @$scope.open_doc_id and !options.forceReopen
|
||||
@$scope.open_doc_id = doc.id
|
||||
console.log "Actually opening doc", doc.id
|
||||
|
||||
$.localStorage "doc.open_id.#{@$scope.project_id}", doc.id
|
||||
@ide.fileTreeManager.selectEntity(doc)
|
||||
|
||||
@$scope.editor.opening = true
|
||||
@_openNewDocument doc, (error, sharejs_doc) =>
|
||||
console.log "OPENED DOC", error, sharejs_doc
|
||||
if error?
|
||||
@ide.showGenericServerErrorMessage()
|
||||
return
|
||||
|
||||
@$scope.$apply () =>
|
||||
@$scope.editor.opening = false
|
||||
@$scope.editor.sharejs_doc = sharejs_doc
|
||||
|
||||
_openNewDocument: (doc, callback = (error, sharejs_doc) ->) ->
|
||||
|
@ -55,28 +60,30 @@ define [
|
|||
|
||||
new_sharejs_doc.join (error) =>
|
||||
return callback(error) if error?
|
||||
@_bindToDocumentEvents(new_sharejs_doc)
|
||||
@_bindToDocumentEvents(doc, new_sharejs_doc)
|
||||
callback null, new_sharejs_doc
|
||||
|
||||
_bindToDocumentEvents: (document) ->
|
||||
_bindToDocumentEvents: (doc, sharejs_doc) ->
|
||||
sharejs_doc.on "error", (error) =>
|
||||
console.error "DOC ERROR", error
|
||||
@openDoc(doc, forceReopen: true)
|
||||
|
||||
document.on "error", (error) =>
|
||||
@openDoc(document.doc_id, forceReopen: true)
|
||||
#TODO!!!
|
||||
# Modal.createModal
|
||||
# title: "Out of sync"
|
||||
# message: "Sorry, this file has gone out of sync and we need to do a full refresh. Please let us know if this happens frequently."
|
||||
# buttons:[
|
||||
# text: "Ok"
|
||||
# ]
|
||||
|
||||
Modal.createModal
|
||||
title: "Out of sync"
|
||||
message: "Sorry, this file has gone out of sync and we need to do a full refresh. Please let us know if this happens frequently."
|
||||
buttons:[
|
||||
text: "Ok"
|
||||
]
|
||||
|
||||
document.on "externalUpdate", () =>
|
||||
Modal.createModal
|
||||
title: "Document Updated Externally"
|
||||
message: "This document was just updated externally. Any recent changes you have made may have been overwritten. To see previous versions please look in the history."
|
||||
buttons:[
|
||||
text: "Ok"
|
||||
]
|
||||
sharejs_doc.on "externalUpdate", () =>
|
||||
#TODO!!!
|
||||
# Modal.createModal
|
||||
# title: "Document Updated Externally"
|
||||
# message: "This document was just updated externally. Any recent changes you have made may have been overwritten. To see previous versions please look in the history."
|
||||
# buttons:[
|
||||
# text: "Ok"
|
||||
# ]
|
||||
|
||||
_unbindFromDocumentEvents: (document) ->
|
||||
document.off()
|
||||
|
|
Loading…
Reference in a new issue