add missing cleanup in chat store
This commit is contained in:
parent
c7c85af6b4
commit
7ce307ece2
1 changed files with 12 additions and 1 deletions
|
|
@ -61,6 +61,9 @@ abstract class ChatStoreBase with Store {
|
|||
|
||||
WebSocketChannel? _sevenTVChannel;
|
||||
|
||||
/// The subscription that handles the 7TV WebSocket connection.
|
||||
StreamSubscription? _sevenTVChannelListener;
|
||||
|
||||
static const _maxRetries = 5;
|
||||
|
||||
// The retry counter for exponential backoff.
|
||||
|
|
@ -517,7 +520,9 @@ abstract class ChatStoreBase with Store {
|
|||
}
|
||||
}
|
||||
|
||||
_sevenTVChannel?.stream.listen(
|
||||
// Cancel previous subscription if exists
|
||||
_sevenTVChannelListener?.cancel();
|
||||
_sevenTVChannelListener = _sevenTVChannel?.stream.listen(
|
||||
(data) {
|
||||
if (!settings.showVideo || settings.chatDelay == 0) {
|
||||
listener(data);
|
||||
|
|
@ -777,7 +782,13 @@ abstract class ChatStoreBase with Store {
|
|||
_notificationTimer?.cancel();
|
||||
sleepTimer?.cancel();
|
||||
|
||||
// Cancel WebSocket subscriptions
|
||||
_channelListener?.cancel();
|
||||
_sevenTVChannelListener?.cancel();
|
||||
|
||||
// Close WebSocket channels
|
||||
_channel?.sink.close(1000);
|
||||
_sevenTVChannel?.sink.close(1000);
|
||||
|
||||
for (final reactionDisposer in reactions) {
|
||||
reactionDisposer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue