diff --git a/requirements/app.txt b/requirements/app.txt index 82994b9..68aa43f 100755 --- a/requirements/app.txt +++ b/requirements/app.txt @@ -1,3 +1,3 @@ -galaxy.plugin.api==0.48 +galaxy.plugin.api==0.55 pyobjc-framework-CoreServices==5.1.2; sys_platform == 'darwin' psutil==5.6.1; sys_platform == 'darwin' diff --git a/src/plugin.py b/src/plugin.py index 966b0f1..51347a8 100755 --- a/src/plugin.py +++ b/src/plugin.py @@ -7,7 +7,7 @@ import time import webbrowser from collections import namedtuple -from functools import partial, wraps +from functools import partial from typing import Any, Callable, Dict, List, NewType, Optional from galaxy.api.consts import LicenseType, Platform @@ -43,18 +43,6 @@ def is_windows(): AchievementsImportContext = namedtuple("AchievementsImportContext", ["owned_games", "achievements"]) -def using_cache(method): - @wraps(method) - async def wrapper(self, *args, **kwargs): - result = await method(self, *args, **kwargs) - if self._persistent_cache_updated: - self.push_cache() - self._persistent_cache_updated = False - return result - - return wrapper - - class OriginPlugin(Plugin): # pylint: disable=abstract-method def __init__(self, reader, writer, token): @@ -168,7 +156,6 @@ async def get_unlocked_achievements(self, game_id: str, context: AchievementsImp logging.exception("Failed to parse achievements for game {}".format(game_id)) raise UnknownBackendResponse - @using_cache async def _get_offers(self, offer_ids): """ Get offers from cache if exists. @@ -194,7 +181,7 @@ async def _get_offers(self, offer_ids): offers.append(offer) self._offer_id_cache[offer_id] = offer - self._persistent_cache_updated = True + self.push_cache() return offers @@ -297,7 +284,6 @@ async def prepare_game_times_context(self, game_ids: List[str]) -> Any: return last_played_games - @using_cache async def get_game_time(self, game_id: OfferId, last_played_games: Any) -> GameTime: try: offer = self._offer_id_cache.get(game_id) @@ -318,6 +304,11 @@ async def get_game_time(self, game_id: OfferId, last_played_games: Any) -> GameT logging.exception("Failed to import game times") raise UnknownBackendResponse(str(e)) + def game_times_import_complete(self): + if self._persistent_cache_updated: + self.push_cache() + self._persistent_cache_updated = False + async def get_friends(self): self._check_authenticated() diff --git a/src/version.py b/src/version.py index 9f3abcc..fd12277 100755 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "0.29" +__version__ = "0.30"