fix: crash if changelog cannot be reached

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2025-10-12 01:22:42 +02:00
parent c64d4e9602
commit 249733a5a6
2 changed files with 23 additions and 11 deletions

View File

@ -166,12 +166,16 @@ class ChatRouterViewModel @Inject constructor(
val current = kvStorage.get("currentDestination") val current = kvStorage.get("currentDestination")
setSaveDestination(ChatRouterDestination.fromString(current ?: "")) setSaveDestination(ChatRouterDestination.fromString(current ?: ""))
latestChangelogRead = changelogs.hasSeenCurrent() try {
latestChangelog = changelogs.getLatestChangelogCode() latestChangelogRead = changelogs.hasSeenCurrent()
latestChangelogBody = latestChangelog = changelogs.getLatestChangelogCode()
changelogs.fetchChangelogByVersionCode(latestChangelog.toLong()).rendered latestChangelogBody =
if (!latestChangelogRead) { changelogs.fetchChangelogByVersionCode(latestChangelog.toLong()).rendered
changelogs.markAsSeen() if (!latestChangelogRead) {
changelogs.markAsSeen()
}
} catch (e: Exception) {
e.printStackTrace()
} }
val seenEarlyAccess = kvStorage.getBoolean("spark/earlyAccess/dismissed") val seenEarlyAccess = kvStorage.getBoolean("spark/earlyAccess/dismissed")

View File

@ -61,16 +61,24 @@ class ChangelogsSettingsScreenViewModel @Inject constructor(
suspend fun requestChangelog(version: String) { suspend fun requestChangelog(version: String) {
viewModelScope.launch { viewModelScope.launch {
renderedChangelog = Changelogs( try {
context, renderedChangelog = Changelogs(
kvStorage context,
).fetchChangelogByVersionCode(version.toLong()).rendered kvStorage
).fetchChangelogByVersionCode(version.toLong()).rendered
} catch (e: Exception) {
e.printStackTrace()
}
} }
} }
suspend fun populate() { suspend fun populate() {
viewModelScope.launch { viewModelScope.launch {
index = Changelogs(context, kvStorage).fetchChangelogIndex() try {
index = Changelogs(context, kvStorage).fetchChangelogIndex()
} catch (e: Exception) {
e.printStackTrace()
}
} }
} }
} }