Skip to content

Commit

Permalink
minor fix to previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chieffancypants committed Apr 4, 2016
1 parent 3b2b934 commit 7db32ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions build/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
// Check to make sure this request hasn't already been cached and that
// the requester didn't explicitly ask us to ignore this request:
if (!config.ignoreLoadingBar && !isCached(config)) {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
if (reqsTotal === 0) {
startTimeout = $timeout(function() {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
cfpLoadingBar.start();
}, latencyThreshold);
}
Expand Down Expand Up @@ -307,9 +307,7 @@ angular.module('cfp.loadingBar', [])
$animate = $injector.get('$animate');
}

$rootScope.$broadcast('cfpLoadingBar:completed');
_set(1);

$timeout.cancel(completeTimeout);

// Attempt to aggregate any start/complete calls within 500ms:
Expand All @@ -319,6 +317,7 @@ angular.module('cfp.loadingBar', [])
promise.then(_completeAnimation);
}
$animate.leave(spinner);
$rootScope.$broadcast('cfpLoadingBar:completed');
}, 500);
}

Expand Down
2 changes: 1 addition & 1 deletion build/loading-bar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions src/loading-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ angular.module('cfp.loadingBarInterceptor', ['cfp.loadingBar'])
// Check to make sure this request hasn't already been cached and that
// the requester didn't explicitly ask us to ignore this request:
if (!config.ignoreLoadingBar && !isCached(config)) {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
if (reqsTotal === 0) {
startTimeout = $timeout(function() {
$rootScope.$broadcast('cfpLoadingBar:loading', {url: config.url});
cfpLoadingBar.start();
}, latencyThreshold);
}
Expand Down Expand Up @@ -301,9 +301,7 @@ angular.module('cfp.loadingBar', [])
$animate = $injector.get('$animate');
}

$rootScope.$broadcast('cfpLoadingBar:completed');
_set(1);

$timeout.cancel(completeTimeout);

// Attempt to aggregate any start/complete calls within 500ms:
Expand All @@ -313,6 +311,7 @@ angular.module('cfp.loadingBar', [])
promise.then(_completeAnimation);
}
$animate.leave(spinner);
$rootScope.$broadcast('cfpLoadingBar:completed');
}, 500);
}

Expand Down
2 changes: 1 addition & 1 deletion test/loading-bar-interceptor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ describe 'loadingBarInterceptor Service', ->
expect(startedEventCalled).toBe true

cfpLoadingBar.complete()
expect(completedEventCalled).toBe true
$timeout.flush()
expect(completedEventCalled).toBe true

it 'should debounce the calls to start()', inject (cfpLoadingBar, $rootScope) ->
startedEventCalled = 0
Expand Down

0 comments on commit 7db32ae

Please sign in to comment.