Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 95cb8ec

Browse files
Restoring the functionality to display existing forks
1 parent 8920a70 commit 95cb8ec

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/GitHub.App/ViewModels/Dialog/ForkRepositorySelectViewModel.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)