fix(rpi-connect): use with_state
of the latest python-redux version instead of view
to avoid memoization of actions - closes #248
#256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some actions need data from store, for example
start_service
of rpi connect, needsstate.lightdm.is_active
so that it can decide whether it should show the "LightDM is not running" notification or not.To provide functions, information from the store, we used to use
store.view
decorator but as a bad side effect, it activates memoization for the function, so calling it for the second time, won't actually run it and will just return its previous return value.That's why "start" button of the rpi connect worked only for the first time.
In this pull request we are using the new
store.with_state
decorator wherevermemoization
is not desired in place ofstore.view
.store.with_state
is available in the latest 0.20.0 release of python-redux.Other than that, now rpi-connect's status command, when returning the number of active sessions, uses the plural noun "sessions" for when there are multiple active sessions and singluar noun "session" when there is only one, like "1 session", "2 sessions", etc. So I made the "s" in the regular expression parsing its output optional.