Skip to content

Commit

Permalink
version 0.30
Browse files Browse the repository at this point in the history
  • Loading branch information
FriendsOfGalaxy committed Oct 25, 2019
1 parent 1e7351d commit 446aec6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion requirements/app.txt
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 7 additions & 16 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.29"
__version__ = "0.30"

0 comments on commit 446aec6

Please sign in to comment.