mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: load default github avatar
This commit is contained in:
parent
91daa42c08
commit
85d3f0993c
1 changed files with 3 additions and 12 deletions
|
@ -34,6 +34,9 @@ namespace SourceGit.Models
|
||||||
if (!Directory.Exists(_storePath))
|
if (!Directory.Exists(_storePath))
|
||||||
Directory.CreateDirectory(_storePath);
|
Directory.CreateDirectory(_storePath);
|
||||||
|
|
||||||
|
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/Images/github.png", UriKind.RelativeOrAbsolute));
|
||||||
|
_resources.Add("noreply@github.com", new Bitmap(icon));
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -117,17 +120,6 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
public static Bitmap Request(string email, bool forceRefetch)
|
public static Bitmap Request(string email, bool forceRefetch)
|
||||||
{
|
{
|
||||||
if (email.Equals("noreply@github.com", StringComparison.Ordinal))
|
|
||||||
{
|
|
||||||
if (_githubEmailAvatar == null)
|
|
||||||
{
|
|
||||||
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/Images/github.png", UriKind.RelativeOrAbsolute));
|
|
||||||
_githubEmailAvatar = new Bitmap(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _githubEmailAvatar;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (forceRefetch)
|
if (forceRefetch)
|
||||||
{
|
{
|
||||||
if (_resources.ContainsKey(email))
|
if (_resources.ContainsKey(email))
|
||||||
|
@ -198,6 +190,5 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
[GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@users\.noreply\.github\.com$")]
|
[GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@users\.noreply\.github\.com$")]
|
||||||
private static partial Regex REG_GITHUB_USER_EMAIL();
|
private static partial Regex REG_GITHUB_USER_EMAIL();
|
||||||
private static Bitmap _githubEmailAvatar = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue