@@ -6,8 +6,8 @@ require('app')
66function ControllerInstanceLayout (
77 configLogoutURL ,
88 fetchUser ,
9+ fetchInstances ,
910 $stateParams ,
10- QueryAssist ,
1111 errs ,
1212 $rootScope ,
1313 keypather ,
@@ -27,49 +27,40 @@ function ControllerInstanceLayout(
2727 return errs . handler ( err ) ;
2828 }
2929 thisUser = user ;
30- fetchInstances (
30+ resolveInstanceFetch (
3131 $stateParams . userName
3232 ) ;
3333 } ) ;
3434
35- function fetchInstances ( account , cb ) {
36- if ( ! account ) { return ; }
37- async . series ( [
35+ function resolveInstanceFetch ( username ) {
36+ if ( ! username ) { return ; }
37+ async . waterfall ( [
3838 function ( cb ) {
3939 $rootScope . dataApp . state . loadingInstances = true ;
4040 $rootScope . dataApp . data . instances = null ;
4141 $rootScope . safeApply ( cb ) ;
4242 } ,
4343 function ( cb ) {
44- new QueryAssist ( thisUser , cb )
45- . wrapFunc ( 'fetchInstances' , cb )
46- . query ( {
47- githubUsername : account
48- } )
49- . cacheFetch ( function ( instances , cached , cb ) {
50- if ( account === keypather . get ( $rootScope , 'dataApp.data.activeAccount.oauthName()' ) ) {
51- if ( $rootScope . dataApp . data . instances !== instances ) {
52- $rootScope . dataApp . data . instances = instances ;
53- }
54- $rootScope . dataApp . state . loadingInstances = false ;
55- $rootScope . safeApply ( cb ) ;
56- } else {
57- cb ( ) ;
58- }
59- } )
60- . resolve ( function ( err , projects , cb ) {
61- cb ( err ) ;
62- } )
63- . go ( ) ;
44+ fetchInstances ( username , true , cb ) ;
6445 } ,
65- cb
46+ function ( instances , queriedUsername , cb ) {
47+ if ( username === keypather . get ( $rootScope , 'dataApp.data.activeAccount.oauthName()' ) ) {
48+ if ( $rootScope . dataApp . data . instances !== instances ) {
49+ $rootScope . dataApp . data . instances = instances ;
50+ }
51+ $rootScope . dataApp . state . loadingInstances = false ;
52+ $rootScope . safeApply ( cb ) ;
53+ } else {
54+ cb ( ) ;
55+ }
56+ }
6657 ] , function ( err ) {
67- if ( err ) { throw err ; }
58+ if ( err ) { return errs . handler ( err ) ; }
6859 } ) ;
6960 }
7061
7162 var instanceListUnwatcher = $scope . $on ( 'INSTANCE_LIST_FETCH' , function ( event , username ) {
72- fetchInstances ( username ) ;
63+ resolveInstanceFetch ( username ) ;
7364 } ) ;
7465
7566 $scope . $on ( '$destroy' , function ( ) {
0 commit comments