Inventory fetch now sorts campaigns
This commit is contained in:
1 parent
2e7f19be0d
commit
a3ca61f1c7
1 file changed
+6
-8
@@ -687,14 +687,12 @@ class Twitch:
|
|||||||
|
|
||||||
async def fetch_inventory(self) -> None:
|
async def fetch_inventory(self) -> None:
|
||||||
response = await self.gql_request(GQL_OPERATIONS["Inventory"])
|
response = await self.gql_request(GQL_OPERATIONS["Inventory"])
|
||||||
inventory = response["data"]["currentUser"]["inventory"]
|
inventory = response["data"]["currentUser"]["inventory"]["dropCampaignsInProgress"] or []
|
||||||
if inventory["dropCampaignsInProgress"]: # None with no available campaigns
|
campaigns = sorted(
|
||||||
self.inventory = [
|
(DropsCampaign(self, data) for data in inventory),
|
||||||
DropsCampaign(self, data) for data in inventory["dropCampaignsInProgress"]
|
key=lambda c: c.ends_at,
|
||||||
]
|
)
|
||||||
else:
|
self.inventory = campaigns
|
||||||
# can happen if the user has no active campaigns yet
|
|
||||||
self.inventory = []
|
|
||||||
|
|
||||||
def get_drop(self, drop_id: str) -> Optional[TimedDrop]:
|
def get_drop(self, drop_id: str) -> Optional[TimedDrop]:
|
||||||
for campaign in self.inventory:
|
for campaign in self.inventory:
|
||||||
|
|||||||
Reference in new issue
Block a user