Explorar o código

Better view refresh after refreshing linked file

Shane Kilkelly %!s(int64=8) %!d(string=hai) anos
pai
achega
656d40ac39

+ 0 - 14
services/web/public/coffee/ide/binary-files/BinaryFilesManager.coffee

@@ -19,17 +19,3 @@ 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
-			)

+ 14 - 2
services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee

@@ -47,6 +47,18 @@ define [
 			else
 				return url
 
+		_tryOpenFile = (new_file_id) ->
+			iterations = 0
+			do tryOpen = () ->
+				if iterations > 10
+					return
+				iterations += 1
+				newFile = ide.fileTreeManager.findEntityById(new_file_id)
+				if newFile?
+					ide.binaryFilesManager.openFile(newFile)
+				else
+					setTimeout(tryOpen, 500)
+
 		$scope.refreshFile = (file) ->
 			$scope.refreshing = true
 			$scope.refreshError = null
@@ -56,8 +68,8 @@ define [
 					{ new_file_id } = data
 					$timeout(
 						() ->
-							ide.binaryFilesManager.openFileById(new_file_id)
-						, 1000
+							_tryOpenFile(new_file_id)
+						, 0
 					)
 					$scope.refreshError = null
 				.catch (response) ->

+ 0 - 9
services/web/public/coffee/ide/file-tree/FileTreeManager.coffee

@@ -87,15 +87,6 @@ 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()