Utilize inventory changed events to manage the overview tab;

instead of the progress notification system
This commit is contained in:
DevilXD
2022-04-27 19:17:43 +02:00
parent a92f6be1a8
commit 0b32d09285
2 changed files with 9 additions and 2 deletions

2
gui.py
View File

@@ -1460,7 +1460,7 @@ class GUIManager:
self, drop: TimedDrop, *, countdown: bool = True, subone: bool = False
) -> None:
self.progress.display(drop, countdown=countdown, subone=subone) # main tab
self.inv.update_drop(drop) # inventory
# inventory overview is updated from within drops themselves via change events
self.tray.update_title(drop) # tray
def print(self, *args, **kwargs):

View File

@@ -13,8 +13,8 @@ if TYPE_CHECKING:
from collections import abc
from twitch import Twitch
from gui import GUIManager
from constants import JsonType
from gui import GUIManager, InventoryOverview
DIMS_PATTERN = re.compile(r'-\d+x\d+(?=\.(?:jpg|png|gif)$)', re.I)
@@ -141,6 +141,7 @@ class TimedDrop(BaseDrop):
):
super().__init__(campaign, data, claimed_benefits)
self._manager: GUIManager = self._twitch.gui
self._gui_inv: InventoryOverview = self._manager.inv
self.current_minutes: int = 0
if "self" in data:
self.current_minutes = data["self"]["currentMinutesWatched"]
@@ -170,9 +171,15 @@ class TimedDrop(BaseDrop):
def progress(self) -> float:
return self.current_minutes / self.required_minutes
def _on_claim(self) -> None:
result = super()._on_claim()
self._gui_inv.update_drop(self)
return result
def _on_minutes_changed(self) -> None:
invalidate_cache(self, "progress", "remaining_minutes")
self.campaign._on_minutes_changed()
self._gui_inv.update_drop(self)
async def claim(self) -> bool:
result = await super().claim()