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,6 +166,7 @@ class ChatRouterViewModel @Inject constructor(
val current = kvStorage.get("currentDestination") val current = kvStorage.get("currentDestination")
setSaveDestination(ChatRouterDestination.fromString(current ?: "")) setSaveDestination(ChatRouterDestination.fromString(current ?: ""))
try {
latestChangelogRead = changelogs.hasSeenCurrent() latestChangelogRead = changelogs.hasSeenCurrent()
latestChangelog = changelogs.getLatestChangelogCode() latestChangelog = changelogs.getLatestChangelogCode()
latestChangelogBody = latestChangelogBody =
@ -173,6 +174,9 @@ class ChatRouterViewModel @Inject constructor(
if (!latestChangelogRead) { if (!latestChangelogRead) {
changelogs.markAsSeen() changelogs.markAsSeen()
} }
} catch (e: Exception) {
e.printStackTrace()
}
val seenEarlyAccess = kvStorage.getBoolean("spark/earlyAccess/dismissed") val seenEarlyAccess = kvStorage.getBoolean("spark/earlyAccess/dismissed")
val seenSwipeToReply = kvStorage.getBoolean("spark/swipeToReply/dismissed") val seenSwipeToReply = kvStorage.getBoolean("spark/swipeToReply/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 {
try {
renderedChangelog = Changelogs( renderedChangelog = Changelogs(
context, context,
kvStorage kvStorage
).fetchChangelogByVersionCode(version.toLong()).rendered ).fetchChangelogByVersionCode(version.toLong()).rendered
} catch (e: Exception) {
e.printStackTrace()
}
} }
} }
suspend fun populate() { suspend fun populate() {
viewModelScope.launch { viewModelScope.launch {
try {
index = Changelogs(context, kvStorage).fetchChangelogIndex() index = Changelogs(context, kvStorage).fetchChangelogIndex()
} catch (e: Exception) {
e.printStackTrace()
}
} }
} }
} }