This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -144,22 +144,28 @@ export class IntegrationManagers {
144144 return this . _managers . length > 0 ;
145145 }
146146
147+ getOrderedManagers ( ) : IntegrationManagerInstance [ ] {
148+ const ordered = [ ] ;
149+ for ( const kind of KIND_PREFERENCE ) {
150+ const managers = this . _managers . filter ( m => m . kind === kind ) ;
151+ if ( ! managers || ! managers . length ) continue ;
152+
153+ if ( kind === KIND_ACCOUNT ) {
154+ // Order by state_keys (IDs)
155+ managers . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) ;
156+ }
157+
158+ ordered . push ( ...managers ) ;
159+ }
160+ return ordered ;
161+ }
162+
147163 getPrimaryManager ( ) : IntegrationManagerInstance {
148164 if ( this . hasManager ( ) ) {
149165 if ( this . _primaryManager ) return this . _primaryManager ;
150166
151- for ( const kind of KIND_PREFERENCE ) {
152- const managers = this . _managers . filter ( m => m . kind === kind ) ;
153- if ( ! managers || ! managers . length ) continue ;
154-
155- if ( kind === KIND_ACCOUNT ) {
156- // Order by state_keys (IDs)
157- managers . sort ( ( a , b ) => a . id . localeCompare ( b . id ) ) ;
158- }
159-
160- this . _primaryManager = managers [ 0 ] ;
161- return this . _primaryManager ;
162- }
167+ this . _primaryManager = this . getOrderedManagers ( ) [ 0 ] ;
168+ return this . _primaryManager ;
163169 } else {
164170 return null ;
165171 }
You can’t perform that action at this time.
0 commit comments