Skip to content

Commit

Permalink
Show tip to disconnect plugin for affected people (#153)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGoogle authored Feb 12, 2021
1 parent 7c0eb2a commit 1a049cd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Unreleased
## Version 0.9.4
(!) WARNING: If you're Humble subscriber, plugin reconnection is needed to sync subscriptions again (!)

[Fixed]
- Plugin being offline for subscribers
- Plugin being offline for subscribers and no subscriptions shown in Settings->Features #151

## Version 0.9.3

Expand Down
12 changes: 12 additions & 0 deletions src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ async def _do_auth(self, auth_cookie) -> Authentication:

async def authenticate(self, stored_credentials=None):
show_news = self.__is_after_minor_update()
just_after_broken_sub_version = self.__is_after_broken_subscriptions_version() # remove after ~04.2021
self._save_cache('last_version', __version__)

if not stored_credentials:
Expand All @@ -137,6 +138,13 @@ async def authenticate(self, stored_credentials=None):

logging.info('Stored credentials found')
auth: Authentication = await self._do_auth(stored_credentials)

# To be removed around 04.2021
# After fixing bug with offline plugin for subscribers (#151),
# reconnection is need to make Galaxy recognize `get_subscriptions` feature again.
if just_after_broken_sub_version and await self._api.had_subscription():
show_news = True

if show_news:
self._open_config(OPTIONS_MODE.NEWS)
return auth
Expand All @@ -148,6 +156,10 @@ async def pass_login_credentials(self, step, credentials, cookies):
self._open_config(OPTIONS_MODE.WELCOME)
return auth

def __is_after_broken_subscriptions_version(self):
"""Returns True once after update from pre 0.9.4"""
return __version__ == '0.9.4' and self._last_version is not None and __version__ != self._last_version

def __is_after_minor_update(self) -> bool:
def cut_to_minor(ver: str) -> LooseVersion:
"""3 part version assumed"""
Expand Down
25 changes: 25 additions & 0 deletions tests/common/test_opening_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,28 @@ async def test_open_options_on_clicking_install(plugin, delayed_fn):
delayed_fn(0.2, plugin.install_game)
)
plugin._open_config.assert_called_once()


@pytest.mark.asyncio
@pytest.mark.parametrize('had_sub', [True, False])
@pytest.mark.parametrize('curr_ver, last_ver, proper_versions', [
('0.9.4', '0.9.3', True),
('0.9.4', '0.9.0', True),
('0.9.4', '0.9.4', False),
('0.9.5', '0.9.4', False),
('0.10.5', '0.10.1', False),
])
async def test_open_news_on_0_9_4_version(
had_sub, curr_ver, last_ver, proper_versions,
api_mock, plugin, auth_cookie, mocker
):
plugin._open_config = MagicMock(spec=())
api_mock.had_subscription.return_value = had_sub
plugin._last_version = last_ver
mocker.patch('plugin.__version__', curr_ver)
await plugin.authenticate(stored_credentials=auth_cookie)
if proper_versions and had_sub:
plugin._open_config.assert_called_once_with(OPTIONS_MODE.NEWS)
api_mock.had_subscription.assert_called_once()
else:
plugin._open_config.assert_not_called()

0 comments on commit 1a049cd

Please sign in to comment.