From 19d870094789027a9916f12f62403fbf73d1a6de Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 25 May 2018 10:36:39 +0100 Subject: [PATCH] Use `waitFor` when refreshing the binary file view --- .../controllers/BinaryFileController.coffee | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee index fddf315f66..ddff96e1d4 100644 --- a/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee +++ b/services/web/public/coffee/ide/binary-files/controllers/BinaryFileController.coffee @@ -47,18 +47,6 @@ 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 @@ -68,7 +56,13 @@ define [ { new_file_id } = data $timeout( () -> - _tryOpenFile(new_file_id) + ide.waitFor( + () -> + ide.fileTreeManager.findEntityById(new_file_id) + (newFile) -> + ide.binaryFilesManager.openFile(newFile) + 5000 + ) , 0 ) $scope.refreshError = null