Fix the reloading of file view after refreshing linked file

This commit is contained in:
Shane Kilkelly 2018-05-18 10:35:02 +01:00
parent 2345b77ea7
commit 94a599d530
4 changed files with 34 additions and 4 deletions

View file

@ -27,7 +27,7 @@ module.exports = LinkedFilesController = {
if error?
logger.error {err: error, project_id, name, linkedFileData, parent_folder_id, user_id}, 'error writing linked file to disk'
return Agent.handleError(error, req, res, next)
EditorController.upsertFile project_id, parent_folder_id, name, fsPath, linkedFileData, "upload", user_id, (error) ->
EditorController.upsertFile project_id, parent_folder_id, name, fsPath, linkedFileData, "upload", user_id, (error, file) ->
return next(error) if error?
res.send(204) # created
res.json(new_file_id: file._id) # created
}

View file

@ -19,3 +19,17 @@ define [
, 0
, this
)
openFileById: (id) ->
file = @ide.fileTreeManager.selectEntityById(id)
@$scope.ui.view = "file"
@$scope.openFile = null
@$scope.$apply()
window.setTimeout(
() =>
@$scope.openFile = file
@$scope.$apply()
@$scope.$digest()
, 0
, this
)

View file

@ -49,8 +49,15 @@ define [
$scope.refreshFile = (file) ->
$scope.refreshing = true
ide.fileTreeManager.refreshLinkedFile(file)
.then () ->
loadTextFileFilePreview()
.then (response) ->
{ data } = response
new_file_id = data.new_file_id
$timeout(
() ->
ide.binaryFilesManager.openFileById(new_file_id)
, 1000
)
# loadTextFileFilePreview()
.finally () ->
$scope.refreshing = false

View file

@ -112,6 +112,15 @@ define [
entity.selected = false
entity.selected = true
selectEntityById: (entity_id) ->
@selected_entity_id = entity_id # For reselecting after a reconnect
selected_entity = null
@ide.fileTreeManager.forEachEntity (entity) ->
if entity.id == entity_id
selected_entity = entity
entity.selected = true
return selected_entity
toggleMultiSelectEntity: (entity) ->
entity.multiSelected = !entity.multiSelected
@$scope.multiSelectedCount = @multiSelectedCount()