-
-
Notifications
You must be signed in to change notification settings - Fork 697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wikigames: set initial currentState from Prefs #5354
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes looks good. I think with this change we can also remove this additional logic, since we are persisting the state.
else if (_gameState.value == null || ::currentState.isInitialized.not()) {
"unknown"
}
This has been resolved. |
@@ -236,6 +247,8 @@ class OnThisDayGameViewModel(savedStateHandle: SavedStateHandle) : ViewModel() { | |||
val langToState = totalState.langToState.toMutableMap() | |||
langToState[wikiSite.languageCode] = currentState | |||
Prefs.otdGameState = JsonUtil.encodeToString(TotalGameState(langToState)).orEmpty() | |||
savedStateHandle[KEY_CURRENT_STATE] = JsonUtil.encodeToString(currentState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire game state gets saved to Prefs (on the previous line). Do we really need to duplicate it into savedStateHandle?
What does this do?
This PR sets the current game state from the Prefs when the ViewModel is created.
Also moved the
impression
event to the end ofonGameEnded()
in the case ofgameState
beingnull
.https://phabricator.wikimedia.org/T387418