make channel list's display add channels only on explicit add

This commit is contained in:
DevilXD
2022-02-10 21:34:36 +01:00
parent 3ccbd4c3db
commit 473af57aeb
3 changed files with 10 additions and 10 deletions

View File

@@ -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:

4
gui.py
View File

@@ -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,

View File

@@ -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"]