Skip to content

Commit e5be649

Browse files
committed
fix: Github REST API access rate limit (#60)
1 parent 400d454 commit e5be649

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/App.axaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,11 @@ public override void OnFrameworkInitializationCompleted()
227227
_notificationReceiver = launcher;
228228
desktop.MainWindow = launcher;
229229

230-
if (ViewModels.Preference.Instance.Check4UpdatesOnStartup)
230+
if (ViewModels.Preference.Instance.ShouldCheck4UpdateOnStartup)
231+
{
232+
ViewModels.Preference.Save();
231233
Check4Update();
234+
}
232235
}
233236

234237
base.OnFrameworkInitializationCompleted();

src/ViewModels/Preference.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,31 @@ public int LastActiveTabIdx
278278
set;
279279
} = 0;
280280

281+
public double LastCheckUpdateTime
282+
{
283+
get;
284+
set;
285+
} = 0;
286+
287+
[JsonIgnore]
288+
public bool ShouldCheck4UpdateOnStartup
289+
{
290+
get
291+
{
292+
if (!_check4UpdatesOnStartup)
293+
return false;
294+
295+
var lastCheck = DateTime.UnixEpoch.AddSeconds(LastCheckUpdateTime).ToLocalTime();
296+
var now = DateTime.Now;
297+
298+
if (lastCheck.Year == now.Year && lastCheck.Month == now.Month && lastCheck.Day == now.Day)
299+
return false;
300+
301+
LastCheckUpdateTime = now.Subtract(DateTime.UnixEpoch.ToLocalTime()).TotalSeconds;
302+
return true;
303+
}
304+
}
305+
281306
public static void AddNode(RepositoryNode node, RepositoryNode to = null)
282307
{
283308
var collection = to == null ? _instance._repositoryNodes : to.SubNodes;

0 commit comments

Comments
 (0)