Use more accurate types and checks for drop context

This commit is contained in:
DevilXD committed 2022-02-01 21:01:58 +01:00
1 parent beca65e271
commit e921295613
1 file changed
+8 -4
+8 -4
View File
@@ -370,8 +370,10 @@ class Twitch:
if not use_active: if not use_active:
# we need to use GQL to get the current progress # we need to use GQL to get the current progress
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"]) context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"] drop_data: Optional[JsonType] = (
if drop_data: context["data"]["currentUser"]["dropCurrentSession"]
)
if drop_data is not None:
drop_id = drop_data["dropID"] drop_id = drop_data["dropID"]
drop = self.get_drop(drop_id) drop = self.get_drop(drop_id)
if drop is None: if drop is None:
@@ -515,8 +517,10 @@ class Twitch:
await asyncio.sleep(4) await asyncio.sleep(4)
for attempt in range(8): for attempt in range(8):
context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"]) context = await self.gql_request(GQL_OPERATIONS["CurrentDrop"])
drop_data: JsonType = context["data"]["currentUser"]["dropCurrentSession"] drop_data: Optional[JsonType] = (
if not drop_data or drop_data["dropID"] != drop.id: context["data"]["currentUser"]["dropCurrentSession"]
)
if drop_data is None or drop_data["dropID"] != drop.id:
break break
await asyncio.sleep(2) await asyncio.sleep(2)
self.restart_watching() self.restart_watching()