From c937c4a6fce5f5f5b58e63a32a5378e2dc7814f0 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Tue, 28 Nov 2023 04:13:53 -0500 Subject: [PATCH] Limit reconnect retries to 5 --- lib/screens/channel/chat/stores/chat_store.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/screens/channel/chat/stores/chat_store.dart b/lib/screens/channel/chat/stores/chat_store.dart index 594d6236..8393f569 100644 --- a/lib/screens/channel/chat/stores/chat_store.dart +++ b/lib/screens/channel/chat/stores/chat_store.dart @@ -57,6 +57,8 @@ abstract class ChatStoreBase with Store { StreamSubscription? _sevenTVChannelListener; + static const _maxRetries = 5; + // The retry counter for exponential backoff. var _retries = 0; @@ -451,6 +453,15 @@ abstract class ChatStoreBase with Store { onDone: () async { if (_channel == null) return; + if (_retries >= _maxRetries) { + messageBuffer.add( + IRCMessage.createNotice( + message: 'Disconnected from chat', + ), + ); + return; + } + if (_backoffTime > 0) { // Add notice that chat was disconnected and then wait the backoff time before reconnecting. final notice =