Skip to content

Commit

Permalink
Logic improvement: first scanner iteration: enable notifications as well
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDelsart committed Nov 4, 2024
1 parent c70295a commit 5240088
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tgtg_scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from random import random
from time import sleep
from typing import Dict, List, NoReturn, Union
import copy

from progress.spinner import Spinner

Expand Down Expand Up @@ -104,6 +105,14 @@ def _job(self) -> None:
except TgtgAPIError as err:
log.error(err)
items += self._get_favorites()

# if state is empty (first scanning iteration), initialize it with the current favorite items and set `items_available` property to 0.
# It allows to be able to receive notifications at start if some magic bags are already available.
if not self.state:
self.state = {item.item_id: copy.deepcopy(item) for item in items}
for item in self.state.values():
item.items_available = 0

for item in items:
self._check_item(item)

Expand Down

0 comments on commit 5240088

Please sign in to comment.