Skip to content
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

Fix #5455: Resolve crash in AudioViewModel by initializing state variables #5561

Merged
merged 18 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@ class AudioViewModel @Inject constructor(
processPlayStatusLiveData()
}

fun setStateAndExplorationId(newState: State, id: String) {
state = newState
explorationId = id
fun setStateAndExplorationId(newState: State?, id: String?) {
if (newState != null && id != null) {
state = newState
explorationId = id
}
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
}

fun loadMainContentAudio(allowAutoPlay: Boolean, reloadingContent: Boolean) {
Expand All @@ -88,6 +90,8 @@ class AudioViewModel @Inject constructor(
* @param allowAutoPlay If false, audio is guaranteed not to be autoPlayed.
*/
private fun loadAudio(contentId: String?, allowAutoPlay: Boolean, reloadingMainContent: Boolean) {
// Check if 'state' is initialized before proceeding.
adhiamboperes marked this conversation as resolved.
Show resolved Hide resolved
if (!::state.isInitialized) return
val targetContentId = contentId ?: state.content.contentId
val voiceoverMapping =
state.recordedVoiceoversMap[targetContentId] ?: VoiceoverMapping.getDefaultInstance()
Expand Down
Loading