diff --git a/channel.py b/channel.py index 6330484..39ee5df 100644 --- a/channel.py +++ b/channel.py @@ -179,8 +179,8 @@ class Channel: return self._stream.drops_enabled return False - def display(self): - self._gui_channels.display(self) + def display(self, *, add: bool = False): + self._gui_channels.display(self, add=add) def remove(self): if self._pending_stream_up is not None: diff --git a/gui.py b/gui.py index 441742a..a5c572e 100644 --- a/gui.py +++ b/gui.py @@ -676,7 +676,7 @@ class ChannelList: def clear_selection(self): self._table.selection_set('') - def display(self, channel: Channel): + def display(self, channel: Channel, *, add: bool = False): # priority priority = "✔" if channel.priority else "❌" # status @@ -707,7 +707,7 @@ class ChannelList: self._set(iid, "priority", priority) if points != '': # we still want to display 0 self._set(iid, "points", points) - else: + elif add: self._channel_map[iid] = channel self._insert( iid, diff --git a/twitch.py b/twitch.py index f9d55f9..967aa3b 100644 --- a/twitch.py +++ b/twitch.py @@ -292,7 +292,7 @@ class Twitch: channel_id = channel.id if channel_id not in self.channels: self.channels[channel_id] = channel - channel.display() + channel.display(add=True) # Subscribe to these channel's state updates topics: List[WebsocketTopic] = [ WebsocketTopic( @@ -599,13 +599,13 @@ class Twitch: # } msg_type = message["type"] if msg_type == "points-earned": - data = message["data"] - channel = self.channels.get(int(data["channel_id"])) - points = data["point_gain"]["total_points"] - balance = data["balance"]["balance"] + data: JsonType = message["data"] + channel: Optional[Channel] = self.channels.get(int(data["channel_id"])) + points: int = data["point_gain"]["total_points"] + balance: int = data["balance"]["balance"] if channel is not None: channel.points = balance - self.gui.channels.display(channel) + channel.display() self.gui.print(f"Earned points for watching: {points:3}, total: {balance}") elif msg_type == "claim-available": claim_data = message["data"]["claim"]