OSDN Git Service

TimelineSchedulerで自動更新の無効化が考慮されていない不具合を修正 (thx @kamemory!)
authorKimura Youichi <kim.upsilon@bucyou.net>
Tue, 24 Sep 2019 18:45:20 +0000 (03:45 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Tue, 24 Sep 2019 18:46:15 +0000 (03:46 +0900)
Fixes: c8b60400 ("タイムラインの定期更新に使用するタイマーの間隔を動的に制御する")

OpenTween/Resources/ChangeLog.txt
OpenTween/TimelineScheduler.cs
OpenTween/Tween.cs

index 3633b42..a7b98aa 100644 (file)
@@ -3,6 +3,7 @@
 ==== Ver 2.4.1-dev(2019/xx/xx)
  * FIX: 「タブを一覧の下に表示する」を無効にすると起動時にエラーが発生する不具合を修正 (thx @mulsys!)
  * FIX: 発言一覧の選択状態が正しく描画されない不具合を修正
+ * FIX: 更新間隔を0秒に設定した場合に自動更新が停止されない不具合を修正 (thx @kamemory!)
 
 ==== Ver 2.4.0(2019/09/24)
  * NEW: Twemoji 12.0.0 に対応しました
index 434d151..8dcc166 100644 (file)
@@ -78,6 +78,30 @@ namespace OpenTween
         public TimeSpan UpdateIntervalConfig { get; set; } = Timeout.InfiniteTimeSpan;
         public TimeSpan UpdateAfterSystemResume { get; set; } = Timeout.InfiniteTimeSpan;
 
+        public bool EnableUpdateHome
+            => this.UpdateIntervalHome != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateMention
+            => this.UpdateIntervalMention != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateDm
+            => this.UpdateIntervalDm != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdatePublicSearch
+            => this.UpdateIntervalPublicSearch != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateUser
+            => this.UpdateIntervalUser != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateList
+            => this.UpdateIntervalList != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateConfig
+            => this.UpdateIntervalConfig != Timeout.InfiniteTimeSpan;
+
+        public bool EnableUpdateSystemResume
+            => this.UpdateAfterSystemResume != Timeout.InfiniteTimeSpan;
+
         public Func<Task>? UpdateHome;
         public Func<Task>? UpdateMention;
         public Func<Task>? UpdateDm;
@@ -116,6 +140,9 @@ namespace OpenTween
 
         public void SystemResumed()
         {
+            if (!this.EnableUpdateSystemResume)
+                return;
+
             this.SystemResumedAt = DateTimeUtc.Now;
             this.systemResumeMode = true;
             this.RefreshSchedule();
@@ -145,33 +172,54 @@ namespace OpenTween
             var round = TimeSpan.FromSeconds(1); // 1秒未満の差異であればまとめて実行する
             var tasks = UpdateTask.None;
 
-            var nextScheduledHome = this.LastUpdateHome + this.UpdateIntervalHome;
-            if (nextScheduledHome - now < round)
-                tasks |= UpdateTask.Home;
+            if (this.EnableUpdateHome)
+            {
+                var nextScheduledHome = this.LastUpdateHome + this.UpdateIntervalHome;
+                if (nextScheduledHome - now < round)
+                    tasks |= UpdateTask.Home;
+            }
 
-            var nextScheduledMention = this.LastUpdateMention + this.UpdateIntervalMention;
-            if (nextScheduledMention - now < round)
-                tasks |= UpdateTask.Mention;
+            if (this.EnableUpdateMention)
+            {
+                var nextScheduledMention = this.LastUpdateMention + this.UpdateIntervalMention;
+                if (nextScheduledMention - now < round)
+                    tasks |= UpdateTask.Mention;
+            }
 
-            var nextScheduledDm = this.LastUpdateDm + this.UpdateIntervalDm;
-            if (nextScheduledDm - now < round)
-                tasks |= UpdateTask.Dm;
+            if (this.EnableUpdateDm)
+            {
+                var nextScheduledDm = this.LastUpdateDm + this.UpdateIntervalDm;
+                if (nextScheduledDm - now < round)
+                    tasks |= UpdateTask.Dm;
+            }
 
-            var nextScheduledPublicSearch = this.LastUpdatePublicSearch + this.UpdateIntervalPublicSearch;
-            if (nextScheduledPublicSearch - now < round)
-                tasks |= UpdateTask.PublicSearch;
+            if (this.EnableUpdatePublicSearch)
+            {
+                var nextScheduledPublicSearch = this.LastUpdatePublicSearch + this.UpdateIntervalPublicSearch;
+                if (nextScheduledPublicSearch - now < round)
+                    tasks |= UpdateTask.PublicSearch;
+            }
 
-            var nextScheduledUser = this.LastUpdateUser + this.UpdateIntervalUser;
-            if (nextScheduledUser - now < round)
-                tasks |= UpdateTask.User;
+            if (this.EnableUpdateUser)
+            {
+                var nextScheduledUser = this.LastUpdateUser + this.UpdateIntervalUser;
+                if (nextScheduledUser - now < round)
+                    tasks |= UpdateTask.User;
+            }
 
-            var nextScheduledList = this.LastUpdateList + this.UpdateIntervalList;
-            if (nextScheduledList - now < round)
-                tasks |= UpdateTask.List;
+            if (this.EnableUpdateList)
+            {
+                var nextScheduledList = this.LastUpdateList + this.UpdateIntervalList;
+                if (nextScheduledList - now < round)
+                    tasks |= UpdateTask.List;
+            }
 
-            var nextScheduledConfig = this.LastUpdateConfig + this.UpdateIntervalConfig;
-            if (nextScheduledConfig - now < round)
-                tasks |= UpdateTask.Config;
+            if (this.EnableUpdateConfig)
+            {
+                var nextScheduledConfig = this.LastUpdateConfig + this.UpdateIntervalConfig;
+                if (nextScheduledConfig - now < round)
+                    tasks |= UpdateTask.Config;
+            }
 
             await this.RunUpdateTasks(tasks, now).ConfigureAwait(false);
         }
@@ -264,33 +312,54 @@ namespace OpenTween
             // 次に更新が予定される時刻を判定する
             var min = DateTimeUtc.MaxValue;
 
-            var nextScheduledHome = this.LastUpdateHome + this.UpdateIntervalHome;
-            if (nextScheduledHome < min)
-                min = nextScheduledHome;
+            if (this.EnableUpdateHome)
+            {
+                var nextScheduledHome = this.LastUpdateHome + this.UpdateIntervalHome;
+                if (nextScheduledHome < min)
+                    min = nextScheduledHome;
+            }
 
-            var nextScheduledMention = this.LastUpdateMention + this.UpdateIntervalMention;
-            if (nextScheduledMention < min)
-                min = nextScheduledMention;
+            if (this.EnableUpdateMention)
+            {
+                var nextScheduledMention = this.LastUpdateMention + this.UpdateIntervalMention;
+                if (nextScheduledMention < min)
+                    min = nextScheduledMention;
+            }
 
-            var nextScheduledDm = this.LastUpdateDm + this.UpdateIntervalDm;
-            if (nextScheduledDm < min)
-                min = nextScheduledDm;
+            if (this.EnableUpdateDm)
+            {
+                var nextScheduledDm = this.LastUpdateDm + this.UpdateIntervalDm;
+                if (nextScheduledDm < min)
+                    min = nextScheduledDm;
+            }
 
-            var nextScheduledPublicSearch = this.LastUpdatePublicSearch + this.UpdateIntervalPublicSearch;
-            if (nextScheduledPublicSearch < min)
-                min = nextScheduledPublicSearch;
+            if (this.EnableUpdatePublicSearch)
+            {
+                var nextScheduledPublicSearch = this.LastUpdatePublicSearch + this.UpdateIntervalPublicSearch;
+                if (nextScheduledPublicSearch < min)
+                    min = nextScheduledPublicSearch;
+            }
 
-            var nextScheduledUser = this.LastUpdateUser + this.UpdateIntervalUser;
-            if (nextScheduledUser < min)
-                min = nextScheduledUser;
+            if (this.EnableUpdateUser)
+            {
+                var nextScheduledUser = this.LastUpdateUser + this.UpdateIntervalUser;
+                if (nextScheduledUser < min)
+                    min = nextScheduledUser;
+            }
 
-            var nextScheduledList = this.LastUpdateList + this.UpdateIntervalList;
-            if (nextScheduledList < min)
-                min = nextScheduledList;
+            if (this.EnableUpdateList)
+            {
+                var nextScheduledList = this.LastUpdateList + this.UpdateIntervalList;
+                if (nextScheduledList < min)
+                    min = nextScheduledList;
+            }
 
-            var nextScheduledConfig = this.LastUpdateConfig + this.UpdateIntervalConfig;
-            if (nextScheduledConfig < min)
-                min = nextScheduledConfig;
+            if (this.EnableUpdateConfig)
+            {
+                var nextScheduledConfig = this.LastUpdateConfig + this.UpdateIntervalConfig;
+                if (nextScheduledConfig < min)
+                    min = nextScheduledConfig;
+            }
 
             delay = min - DateTimeUtc.Now;
 
index edfcc65..7756c6d 100644 (file)
@@ -1388,12 +1388,15 @@ namespace OpenTween
 
         private void RefreshTimelineScheduler()
         {
-            this.timelineScheduler.UpdateIntervalHome = TimeSpan.FromSeconds(SettingManager.Common.TimelinePeriod);
-            this.timelineScheduler.UpdateIntervalMention = TimeSpan.FromSeconds(SettingManager.Common.ReplyPeriod);
-            this.timelineScheduler.UpdateIntervalDm = TimeSpan.FromSeconds(SettingManager.Common.DMPeriod);
-            this.timelineScheduler.UpdateIntervalPublicSearch = TimeSpan.FromSeconds(SettingManager.Common.PubSearchPeriod);
-            this.timelineScheduler.UpdateIntervalUser = TimeSpan.FromSeconds(SettingManager.Common.UserTimelinePeriod);
-            this.timelineScheduler.UpdateIntervalList = TimeSpan.FromSeconds(SettingManager.Common.ListsPeriod);
+            static TimeSpan intervalSecondsOrDisabled(int seconds)
+                => seconds == 0 ? Timeout.InfiniteTimeSpan : TimeSpan.FromSeconds(seconds);
+
+            this.timelineScheduler.UpdateIntervalHome = intervalSecondsOrDisabled(SettingManager.Common.TimelinePeriod);
+            this.timelineScheduler.UpdateIntervalMention = intervalSecondsOrDisabled(SettingManager.Common.ReplyPeriod);
+            this.timelineScheduler.UpdateIntervalDm = intervalSecondsOrDisabled(SettingManager.Common.DMPeriod);
+            this.timelineScheduler.UpdateIntervalPublicSearch = intervalSecondsOrDisabled(SettingManager.Common.PubSearchPeriod);
+            this.timelineScheduler.UpdateIntervalUser = intervalSecondsOrDisabled(SettingManager.Common.UserTimelinePeriod);
+            this.timelineScheduler.UpdateIntervalList = intervalSecondsOrDisabled(SettingManager.Common.ListsPeriod);
             this.timelineScheduler.UpdateIntervalConfig = TimeSpan.FromHours(6);
             this.timelineScheduler.UpdateAfterSystemResume = TimeSpan.FromSeconds(30);