Skip to content

Commit

Permalink
fix: added default value to the AppConfig to prevent crashes in some …
Browse files Browse the repository at this point in the history
…cases (#372)
  • Loading branch information
k1rill authored Sep 9, 2024
1 parent ad5c646 commit d282fb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
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

0 comments on commit d282fb0

Please sign in to comment.