From b5b827a363ae809276ae6deaae71930d39d04ac2 Mon Sep 17 00:00:00 2001 From: Juanfran Date: Thu, 18 Jun 2015 09:20:18 +0200 Subject: [PATCH] prevent loader in the issues filter --- app/coffee/app.coffee | 13 +++++++++++-- app/coffee/modules/common/loader.coffee | 11 +++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/coffee/app.coffee b/app/coffee/app.coffee index eda8b865..b6165763 100644 --- a/app/coffee/app.coffee +++ b/app/coffee/app.coffee @@ -559,11 +559,20 @@ init = ($log, $rootscope, $auth, $events, $analytics, $translate, $location, $na # Analytics $analytics.initialize() - $rootscope.$on '$routeChangeStart', (event, next) -> + # On the first page load the loader is painted in `$routeChangeSuccess` + # because we need to hide the tg-navigation-bar. + # In the other cases the loader is in `$routeChangeSuccess` + # because `location.noreload` prevent to execute this event. + un = $rootscope.$on '$routeChangeStart', (event, next) -> if next.loader - loaderService.startWithAutoClose() + loaderService.start(true) + + un() $rootscope.$on '$routeChangeSuccess', (event, next) -> + if next.loader + loaderService.start(true) + if next.access && next.access.requiresLogin if !$auth.isAuthenticated() $location.path($navUrls.resolve("login")) diff --git a/app/coffee/modules/common/loader.coffee b/app/coffee/modules/common/loader.coffee index 3fbed2f2..4ebc0215 100644 --- a/app/coffee/modules/common/loader.coffee +++ b/app/coffee/modules/common/loader.coffee @@ -51,6 +51,7 @@ Loader = ($rootscope) -> minTime: 300 } + open = false startLoadTime = 0 requestCount = 0 lastResponseDate = 0 @@ -68,6 +69,7 @@ Loader = ($rootscope) -> timeout timeoutValue, -> $rootscope.$broadcast("loader:end") + open = false window.prerenderReady = true # Needed by Prerender Server startLoadTime = 0 @@ -93,13 +95,14 @@ Loader = ($rootscope) -> start = () -> startLoadTime = new Date().getTime() $rootscope.$broadcast("loader:start") + open = true return { pageLoaded: pageLoaded - start: start - startWithAutoClose: () -> - start() - autoClose() + start: (auto=false) -> + if !open + start() + autoClose() if auto onStart: (fn) -> $rootscope.$on("loader:start", fn)