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: added default value to the AppConfig to prevent crashes in some cases #372

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -145,10 +145,12 @@ class PreferencesManager(context: Context) : CorePreferences, ProfilePreferences
saveString(APP_CONFIG, appConfigJson)
}
get() {
val appConfigString = getString(APP_CONFIG)
val appConfigString = getString(APP_CONFIG, getDefaultAppConfig())
return Gson().fromJson(appConfigString, AppConfig::class.java)
}

private fun getDefaultAppConfig() = Gson().toJson(AppConfig())

override var lastWhatsNewVersion: String
set(value) {
saveString(LAST_WHATS_NEW_VERSION, value)
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/org/openedx/core/domain/model/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package org.openedx.core.domain.model
import java.io.Serializable

data class AppConfig(
val courseDatesCalendarSync: CourseDatesCalendarSync,
val courseDatesCalendarSync: CourseDatesCalendarSync = CourseDatesCalendarSync(),
) : Serializable

data class CourseDatesCalendarSync(
val isEnabled: Boolean,
val isSelfPacedEnabled: Boolean,
val isInstructorPacedEnabled: Boolean,
val isDeepLinkEnabled: Boolean,
val isEnabled: Boolean = false,
val isSelfPacedEnabled: Boolean = false,
val isInstructorPacedEnabled: Boolean = false,
val isDeepLinkEnabled: Boolean = false,
) : Serializable
Loading