Toast check for updates

This commit is contained in:
Syer10
2022-11-05 12:07:10 -04:00
parent 94cf9d77b5
commit 5f3e3e37e9
2 changed files with 6 additions and 1 deletions

View File

@@ -138,6 +138,8 @@
<string name="version">Version</string>
<string name="server_version">Server version</string>
<string name="whats_new">What\'s new</string>
<string name="update_check_no_new_updates">No new updates available</string>
<string name="update_check_look_for_updates">Searching for updates…</string>
<string name="help_translate">Help translate</string>
<string name="github">Github</string>
<string name="discord">Discord</string>

View File

@@ -11,6 +11,7 @@ import ca.gosyer.jui.domain.settings.interactor.AboutServer
import ca.gosyer.jui.domain.settings.model.About
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker.Update
import ca.gosyer.jui.i18n.MR
import ca.gosyer.jui.uicore.vm.ContextWrapper
import ca.gosyer.jui.uicore.vm.ViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
@@ -55,9 +56,11 @@ class AboutViewModel @Inject constructor(
fun checkForUpdates() {
scope.launch {
toast(MR.strings.update_check_look_for_updates.toPlatformString())
when (val update = updateChecker.await(true, onError = { toast(it.message.orEmpty()) })) {
is Update.UpdateFound -> _updates.emit(update)
else -> Unit
is Update.NoUpdatesFound -> toast(MR.strings.update_check_no_new_updates.toPlatformString())
null -> Unit
}
}
}