Skip to content

Commit 7205183

Browse files
feat: delay timeout more
Give more time for something to give a bad response before we waste the user's time.
1 parent be61175 commit 7205183

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/SiteMonitor/ViewModels/MainWindowViewModel.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace SiteMonitor.ViewModels;
2222
/// </summary>
2323
public partial class MainWindowViewModel : ViewModelBase {
2424
private DateTime? _apiDownSince;
25+
private DateTime? _noChatSince;
2526
[ObservableProperty] private bool _apiUp = true;
2627

2728
[ObservableProperty] private string? _chatTimestamp;
@@ -162,6 +163,7 @@ private async Task PingSite() {
162163
(HttpStatusCode, string?) chat = await SendGetRequest("https://nullinside.com/twitch-bot/v1/bot/chat/timestamp").ConfigureAwait(false);
163164
bool chatNotUpdating = false;
164165
if (HttpStatusCode.OK == chat.Item1 && null != chat.Item2) {
166+
_noChatSince = null;
165167
ChatTimestamp = chat.Item2;
166168
string parsed = ChatTimestamp.Trim('"');
167169
if (DateTime.TryParse(parsed, out DateTime time)) {
@@ -173,8 +175,9 @@ private async Task PingSite() {
173175
}
174176
}
175177
else {
178+
_noChatSince = _noChatSince ?? DateTime.Now;
176179
ChatTimestamp = null;
177-
chatNotUpdating = true;
180+
chatNotUpdating = DateTime.Now - _noChatSince > Constants.MAX_TIME_WITHOUT_CHATS;
178181
}
179182

180183
_apiDownSince = !WebsiteUp || !ApiUp || !NullUp ? _apiDownSince ?? DateTime.Now : null;

0 commit comments

Comments
 (0)