From e33b7b1a4925e0f2672d17d7b6d79c6826e00286 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 25 May 2018 10:37:04 +0100 Subject: [PATCH] Use `waitFor` when restoring a file in v2 history --- .../HistoryV2DiffController.coffee | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/services/web/public/coffee/ide/history/controllers/HistoryV2DiffController.coffee b/services/web/public/coffee/ide/history/controllers/HistoryV2DiffController.coffee index c2ced4cf59..a547f42f94 100644 --- a/services/web/public/coffee/ide/history/controllers/HistoryV2DiffController.coffee +++ b/services/web/public/coffee/ide/history/controllers/HistoryV2DiffController.coffee @@ -24,17 +24,14 @@ define [ $scope.restoreState.inflight = false openEntity = (data) -> - iterations = 0 {id, type} = data - do tryOpen = () -> - if iterations > 5 - return - iterations += 1 - entity = ide.fileTreeManager.findEntityById(id) - if entity? and type == 'doc' - ide.editorManager.openDoc(entity) - else if entity? and type == 'file' - ide.binaryFilesManager.openFile(entity) - else - setTimeout(tryOpen, 500) - \ No newline at end of file + ide.waitFor( + () -> + ide.fileTreeManager.findEntityById(id) + (entity) -> + if type == 'doc' + ide.editorManager.openDoc(entity) + else type == 'file' + ide.binaryFilesManager.openFile(entity) + 3000 + )