mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Keep root doc list in sync with file tree updates
This commit is contained in:
parent
42c63dd5a2
commit
f886f19429
1 changed files with 11 additions and 5 deletions
|
@ -23,49 +23,55 @@ define [
|
||||||
_bindToSocketEvents: () ->
|
_bindToSocketEvents: () ->
|
||||||
@ide.socket.on "reciveNewDoc", (parent_folder_id, doc) =>
|
@ide.socket.on "reciveNewDoc", (parent_folder_id, doc) =>
|
||||||
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
||||||
@$scope.$apply () ->
|
@$scope.$apply () =>
|
||||||
parent_folder.children.push {
|
parent_folder.children.push {
|
||||||
name: doc.name
|
name: doc.name
|
||||||
id: doc._id
|
id: doc._id
|
||||||
type: "doc"
|
type: "doc"
|
||||||
}
|
}
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
@ide.socket.on "reciveNewFile", (parent_folder_id, file) =>
|
@ide.socket.on "reciveNewFile", (parent_folder_id, file) =>
|
||||||
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
||||||
@$scope.$apply () ->
|
@$scope.$apply () =>
|
||||||
parent_folder.children.push {
|
parent_folder.children.push {
|
||||||
name: file.name
|
name: file.name
|
||||||
id: file._id
|
id: file._id
|
||||||
type: "file"
|
type: "file"
|
||||||
}
|
}
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
@ide.socket.on "reciveNewFolder", (parent_folder_id, folder) =>
|
@ide.socket.on "reciveNewFolder", (parent_folder_id, folder) =>
|
||||||
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
parent_folder = @findEntityById(parent_folder_id) or @$scope.rootFolder
|
||||||
@$scope.$apply () ->
|
@$scope.$apply () =>
|
||||||
parent_folder.children.push {
|
parent_folder.children.push {
|
||||||
name: folder.name
|
name: folder.name
|
||||||
id: folder._id
|
id: folder._id
|
||||||
type: "folder"
|
type: "folder"
|
||||||
children: []
|
children: []
|
||||||
}
|
}
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
@ide.socket.on "reciveEntityRename", (entity_id, name) =>
|
@ide.socket.on "reciveEntityRename", (entity_id, name) =>
|
||||||
entity = @findEntityById(entity_id)
|
entity = @findEntityById(entity_id)
|
||||||
return if !entity?
|
return if !entity?
|
||||||
@$scope.$apply () ->
|
@$scope.$apply () =>
|
||||||
entity.name = name
|
entity.name = name
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
@ide.socket.on "removeEntity", (entity_id) =>
|
@ide.socket.on "removeEntity", (entity_id) =>
|
||||||
entity = @findEntityById(entity_id)
|
entity = @findEntityById(entity_id)
|
||||||
return if !entity?
|
return if !entity?
|
||||||
@$scope.$apply () =>
|
@$scope.$apply () =>
|
||||||
@_deleteEntityFromScope entity
|
@_deleteEntityFromScope entity
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
@ide.socket.on "reciveEntityMove", (entity_id, folder_id) =>
|
@ide.socket.on "reciveEntityMove", (entity_id, folder_id) =>
|
||||||
entity = @findEntityById(entity_id)
|
entity = @findEntityById(entity_id)
|
||||||
folder = @findEntityById(folder_id)
|
folder = @findEntityById(folder_id)
|
||||||
@$scope.$apply () =>
|
@$scope.$apply () =>
|
||||||
@_moveEntityInScope(entity, folder)
|
@_moveEntityInScope(entity, folder)
|
||||||
|
@recalculateDocList()
|
||||||
|
|
||||||
selectEntity: (entity) ->
|
selectEntity: (entity) ->
|
||||||
@selected_entity_id = entity.id # For reselecting after a reconnect
|
@selected_entity_id = entity.id # For reselecting after a reconnect
|
||||||
|
|
Loading…
Reference in a new issue