Skip to content

Commit

Permalink
Implement contributors from both repos
Browse files Browse the repository at this point in the history
  • Loading branch information
CarbonNeuron committed Jan 22, 2021
1 parent c525ced commit 7ebe6e9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
46 changes: 40 additions & 6 deletions AUCapture-WPF/Contributors.xaml.cs
Expand Up @@ -29,8 +29,8 @@ namespace AUCapture_WPF
/// </summary>
public partial class Contributors
{
public Queue<RepositoryContributor> RepoContributorsToBeAdded = new();
public ObservableCollection<RepositoryContributor> CurrentContributors = new();
public Queue<BetterRepoContributor> RepoContributorsToBeAdded = new();
public ObservableCollection<BetterRepoContributor> CurrentContributors = new();
public Contributors(bool dark)
{
InitializeComponent();
Expand All @@ -49,10 +49,26 @@ public Contributors(bool dark)
public async void AddContributors()
{
GitHubClient client = new GitHubClient(new ProductHeaderValue("AmongUsCapture"));
IReadOnlyList<RepositoryContributor> repoContribs = await client.Repository.GetAllContributors("automuteus", "amonguscapture");
var tempList = repoContribs.Where(x => x.Id != 49699333).ToList();
tempList.Shuffle();
RepoContributorsToBeAdded = new Queue<RepositoryContributor>(tempList);
var autoMuteUsOrgRepos = new List<int>{294825566, 295776544};
var ListOfContribs = new List<BetterRepoContributor>();
foreach (var repo in autoMuteUsOrgRepos)
{
var RepoContributors = await client.Repository.GetAllContributors(repo);
foreach (var contributor in RepoContributors)
{
if (ListOfContribs.All(x => x.HtmlUrl != contributor.HtmlUrl))
{
ListOfContribs.Add(new BetterRepoContributor(contributor.Id,contributor.Contributions, contributor.AvatarUrl, contributor.HtmlUrl, contributor.Login));
}
else
{
var indexOfReal = ListOfContribs.FindIndex(x => x.HtmlUrl == contributor.HtmlUrl);
ListOfContribs[indexOfReal].Contributions += contributor.Contributions;
}
}
}
var tempList = ListOfContribs.Where(x => x.Id != 49699333).OrderBy(x=>x.Contributions).ToList();
RepoContributorsToBeAdded = new Queue<BetterRepoContributor>(tempList);
CurrentContributors.Add(RepoContributorsToBeAdded.Dequeue());

System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
Expand Down Expand Up @@ -105,4 +121,22 @@ private void Gravatar_MouseDown(object sender, MouseButtonEventArgs e)
OpenBrowser(tarContext.HtmlUrl);
}
}

public class BetterRepoContributor
{
public BetterRepoContributor(long id, int contributions, string avatarUrl, string htmlUrl, string login)
{
Id = id;
Contributions = contributions;
AvatarUrl = avatarUrl;
HtmlUrl = htmlUrl;
Login = login;
}

public long Id { get; set; }
public int Contributions { get; set; }
public string AvatarUrl { get; set; }
public string HtmlUrl { get; set; }
public string Login { get; set; }
}
}
12 changes: 10 additions & 2 deletions AUCapture-WPF/MainWindow.xaml.cs
Expand Up @@ -238,8 +238,16 @@ private void ProcessOnExited(object? sender, EventArgs e)

public async void Update()
{
Version version = new Version(context.Version);
Version latestVersion = new Version(context.LatestVersion);
try
{
Version version = new Version(context.Version);
Version latestVersion = new Version(context.LatestVersion);
}
catch (Exception e)
{
return;
}


#if PUBLISH
if (latestVersion.CompareTo(version) > 0)
Expand Down

0 comments on commit 7ebe6e9

Please sign in to comment.