File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1- using System . Reflection ;
1+ using System ;
2+ using System . Reflection ;
23
34namespace SiteMonitor ;
45
56/// <summary>
67/// Constants used throughout the file.
78/// </summary>
89public class Constants {
10+ /// <summary>
11+ /// The maximum amount of time before alerting the user that we aren't getting chat messages.
12+ /// </summary>
13+ public static readonly TimeSpan MAX_TIME_WITHOUT_CHATS = TimeSpan . FromMinutes ( 30 ) ;
14+
15+ /// <summary>
16+ /// The maximum amount of time before alerting the user that the APIs are down and not automatically coming back up.
17+ /// </summary>
18+ public static readonly TimeSpan MAX_TIME_SERVICE_IS_DOWN = TimeSpan . FromMinutes ( 5 ) ;
19+
920 /// <summary>
1021 /// The version of the application being run right now.
1122 /// </summary>
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ namespace SiteMonitor.ViewModels;
2121/// The view model for the main UI.
2222/// </summary>
2323public partial class MainWindowViewModel : ViewModelBase {
24+ private DateTime ? _apiDownSince ;
2425 [ ObservableProperty ] private bool _apiUp = true ;
2526
2627 [ ObservableProperty ] private string ? _chatTimestamp ;
@@ -168,15 +169,17 @@ private async Task PingSite() {
168169 TimeSpan diff = DateTime . Now - time . ToLocalTime ( ) ;
169170 timestamp = $ "{ timestamp } ({ diff . Hours } h { diff . Minutes } m { diff . Seconds } s ago)";
170171 ChatTimestamp = timestamp ;
171- chatNotUpdating = diff > TimeSpan . FromMinutes ( 5 ) ;
172+ chatNotUpdating = diff > Constants . MAX_TIME_WITHOUT_CHATS ;
172173 }
173174 }
174175 else {
175176 ChatTimestamp = null ;
176177 chatNotUpdating = true ;
177178 }
178179
179- if ( ( ! WebsiteUp || ! ApiUp || ! NullUp || chatNotUpdating ) && IsMinimized ) {
180+ _apiDownSince = ! WebsiteUp || ! ApiUp || ! NullUp ? _apiDownSince ?? DateTime . Now : null ;
181+ bool apiNotComingUp = DateTime . Now - _apiDownSince > Constants . MAX_TIME_SERVICE_IS_DOWN ;
182+ if ( ( apiNotComingUp || chatNotUpdating ) && IsMinimized ) {
180183 WindowState = WindowState . Normal ;
181184 }
182185
You can’t perform that action at this time.
0 commit comments