@@ -84,7 +84,7 @@ public async Task InitializeAsync(ILocalRepositoryModel repository, IConnection
8484 current = current . Parent ;
8585 }
8686
87- Accounts = BuildAccounts ( x . Accounts , repository , forks , parents ) ;
87+ BuildAccounts ( x . Accounts , repository , forks , parents ) ;
8888 } ) ;
8989
9090 }
@@ -95,16 +95,19 @@ public async Task InitializeAsync(ILocalRepositoryModel repository, IConnection
9595 }
9696 }
9797
98- IReadOnlyList < IAccount > BuildAccounts ( IReadOnlyList < IAccount > accessibleAccounts , ILocalRepositoryModel currentRepository , IList < IRemoteRepositoryModel > forks , List < IRemoteRepositoryModel > parents )
98+ void BuildAccounts ( IReadOnlyList < IAccount > accessibleAccounts , ILocalRepositoryModel currentRepository , IList < IRemoteRepositoryModel > forks , List < IRemoteRepositoryModel > parents )
9999 {
100100 log . Verbose ( "BuildAccounts: {AccessibleAccounts} accessibleAccounts, {Forks} forks, {Parents} parents" , accessibleAccounts . Count , forks . Count , parents . Count ) ;
101101
102102 var existingForksAndParents = forks . Union ( parents ) . ToDictionary ( model => model . Owner ) ;
103103
104- return accessibleAccounts
105- . Where ( x => x . Login != currentRepository . Owner )
106- . Where ( x => ! existingForksAndParents . ContainsKey ( x . Login ) )
107- . ToList ( ) ;
104+ var readOnlyList = accessibleAccounts
105+ . Where ( account => account . Login != currentRepository . Owner )
106+ . Select ( account => new { Account = account , Fork = existingForksAndParents . ContainsKey ( account . Login ) ? existingForksAndParents [ account . Login ] : null } )
107+ . ToArray ( ) ;
108+
109+ Accounts = readOnlyList . Where ( arg => arg . Fork == null ) . Select ( arg => arg . Account ) . ToList ( ) ;
110+ ExistingForks = readOnlyList . Where ( arg => arg . Fork != null ) . Select ( arg => arg . Fork ) . ToList ( ) ;
108111 }
109112 }
110113}
0 commit comments