Remove inventory lock to fix a bug;

with campaign not refreshing once all drops are mined
This commit is contained in:
DevilXD committed 2022-02-04 16:52:14 +01:00
1 parent e921295613
commit b0007eaab2
1 file changed
+3 -3
+3 -3
View File
@@ -55,7 +55,6 @@ class Twitch:
self._state_change = asyncio.Event() self._state_change = asyncio.Event()
self.game: Optional[Game] = None self.game: Optional[Game] = None
self.inventory: Dict[Game, List[DropsCampaign]] = {} self.inventory: Dict[Game, List[DropsCampaign]] = {}
self._inv_lock = asyncio.Lock()
# GUI # GUI
self.gui = GUIManager(self) self.gui = GUIManager(self)
# Cookies, session and auth # Cookies, session and auth
@@ -490,7 +489,6 @@ class Twitch:
if msg_type not in ("drop-progress", "drop-claim"): if msg_type not in ("drop-progress", "drop-claim"):
return return
drop_id: str = message["data"]["drop_id"] drop_id: str = message["data"]["drop_id"]
async with self._inv_lock:
drop: Optional[TimedDrop] = self.get_drop(drop_id) drop: Optional[TimedDrop] = self.get_drop(drop_id)
if msg_type == "drop-claim": if msg_type == "drop-claim":
if drop is None: if drop is None:
@@ -523,7 +521,10 @@ class Twitch:
if drop_data is None or drop_data["dropID"] != drop.id: if drop_data is None or drop_data["dropID"] != drop.id:
break break
await asyncio.sleep(2) await asyncio.sleep(2)
if campaign.remaining_drops:
self.restart_watching() self.restart_watching()
else:
self.change_state(State.INVENTORY_FETCH)
return return
assert msg_type == "drop-progress" assert msg_type == "drop-progress"
watching_channel = self.watching_channel.get_with_default(None) watching_channel = self.watching_channel.get_with_default(None)
@@ -777,7 +778,6 @@ class Twitch:
return DropsCampaign(self, response["data"]["user"]["dropCampaign"], claimed_benefits) return DropsCampaign(self, response["data"]["user"]["dropCampaign"], claimed_benefits)
async def fetch_inventory(self) -> None: async def fetch_inventory(self) -> None:
async with self._inv_lock:
# fetch all available campaign IDs, that are currently ACTIVE and account is connected # fetch all available campaign IDs, that are currently ACTIVE and account is connected
response = await self.gql_request(GQL_OPERATIONS["Campaigns"]) response = await self.gql_request(GQL_OPERATIONS["Campaigns"])
data = response["data"]["currentUser"]["dropCampaigns"] or [] data = response["data"]["currentUser"]["dropCampaigns"] or []