From 5aed17885bfdae17bd01cdd59f6ed72e2495a677 Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Mon, 11 Jan 2021 21:38:13 +0000 Subject: [PATCH] Bugfix on calculating sync interval. #1120 --- src/OutlookGoogleCalendarSync/Sync/Timer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/Sync/Timer.cs b/src/OutlookGoogleCalendarSync/Sync/Timer.cs index 339dda61..4fd8fe4d 100644 --- a/src/OutlookGoogleCalendarSync/Sync/Timer.cs +++ b/src/OutlookGoogleCalendarSync/Sync/Timer.cs @@ -66,15 +66,18 @@ public void SetNextSync(int delayMins, Boolean fromNow = false, Boolean calculat if (Settings.Instance.SyncInterval != 0) { DateTime now = DateTime.Now; this.NextSyncDate = fromNow ? now.AddMinutes(delayMins) : LastSyncDate.AddMinutes(delayMins); - if (calculateInterval) CalculateInterval(); + } + if (calculateInterval) CalculateInterval(); + } - } else { + public void CalculateInterval() { + if (Settings.Instance.SyncInterval == 0) { Forms.Main.Instance.NextSyncVal = "Inactive"; Activate(false); log.Info("Schedule disabled."); + return; } - } - public void CalculateInterval() { + DateTime now = DateTime.Now; double interval = (this.nextSyncDate - now).TotalMinutes;