fix: Github REST API access rate limit (#60)

This commit is contained in:
leo 2024-04-07 09:51:55 +08:00
parent 400d454478
commit e5be649a2d
2 changed files with 29 additions and 1 deletions

View file

@ -227,8 +227,11 @@ namespace SourceGit
_notificationReceiver = launcher; _notificationReceiver = launcher;
desktop.MainWindow = launcher; desktop.MainWindow = launcher;
if (ViewModels.Preference.Instance.Check4UpdatesOnStartup) if (ViewModels.Preference.Instance.ShouldCheck4UpdateOnStartup)
{
ViewModels.Preference.Save();
Check4Update(); Check4Update();
}
} }
base.OnFrameworkInitializationCompleted(); base.OnFrameworkInitializationCompleted();

View file

@ -278,6 +278,31 @@ namespace SourceGit.ViewModels
set; set;
} = 0; } = 0;
public double LastCheckUpdateTime
{
get;
set;
} = 0;
[JsonIgnore]
public bool ShouldCheck4UpdateOnStartup
{
get
{
if (!_check4UpdatesOnStartup)
return false;
var lastCheck = DateTime.UnixEpoch.AddSeconds(LastCheckUpdateTime).ToLocalTime();
var now = DateTime.Now;
if (lastCheck.Year == now.Year && lastCheck.Month == now.Month && lastCheck.Day == now.Day)
return false;
LastCheckUpdateTime = now.Subtract(DateTime.UnixEpoch.ToLocalTime()).TotalSeconds;
return true;
}
}
public static void AddNode(RepositoryNode node, RepositoryNode to = null) public static void AddNode(RepositoryNode node, RepositoryNode to = null)
{ {
var collection = to == null ? _instance._repositoryNodes : to.SubNodes; var collection = to == null ? _instance._repositoryNodes : to.SubNodes;