mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-22 13:51:15 +08:00
refactor: load default github avatar
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user