refactor: load default github avatar

This commit is contained in:
leo 2024-08-05 20:12:41 +08:00
parent 91daa42c08
commit 85d3f0993c
No known key found for this signature in database

View file

@ -34,6 +34,9 @@ namespace SourceGit.Models
if (!Directory.Exists(_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(() =>
{
while (true)
@ -117,17 +120,6 @@ namespace SourceGit.Models
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 (_resources.ContainsKey(email))
@ -198,6 +190,5 @@ namespace SourceGit.Models
[GeneratedRegex(@"^(?:(\d+)\+)?(.+?)@users\.noreply\.github\.com$")]
private static partial Regex REG_GITHUB_USER_EMAIL();
private static Bitmap _githubEmailAvatar = null;
}
}