From 8d5f66c6545612d11e588083c58c03731fe95ad6 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Wed, 12 Jan 2022 17:48:25 +0100 Subject: [PATCH] Ensure CHANNEL_CLEANUP stops watching a channel that's about to be removed --- twitch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/twitch.py b/twitch.py index 1d63fcb..aa5bec4 100644 --- a/twitch.py +++ b/twitch.py @@ -238,7 +238,7 @@ class Twitch: elif self._state is State.CHANNELS_CLEANUP: # remove all channels that are offline, # or aren't streaming the game we want anymore - to_remove = [ + to_remove: List[Channel] = [ channel for channel in self.channels.values() if not (channel.online or channel.pending_online) or channel.game is None or channel.game != selected_game @@ -248,6 +248,9 @@ class Twitch: for channel in to_remove ) for channel in to_remove: + if self.is_watching(channel): + # we're removing a channel we're watching + self.stop_watching() del self.channels[channel.id] channel.remove() self.gui.channels.shrink()