mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-14 08:42:06 +01:00
Toast check for updates
This commit is contained in:
@@ -138,6 +138,8 @@
|
|||||||
<string name="version">Version</string>
|
<string name="version">Version</string>
|
||||||
<string name="server_version">Server version</string>
|
<string name="server_version">Server version</string>
|
||||||
<string name="whats_new">What\'s new</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="help_translate">Help translate</string>
|
||||||
<string name="github">Github</string>
|
<string name="github">Github</string>
|
||||||
<string name="discord">Discord</string>
|
<string name="discord">Discord</string>
|
||||||
|
|||||||
@@ -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.settings.model.About
|
||||||
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker
|
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker
|
||||||
import ca.gosyer.jui.domain.updates.interactor.UpdateChecker.Update
|
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.ContextWrapper
|
||||||
import ca.gosyer.jui.uicore.vm.ViewModel
|
import ca.gosyer.jui.uicore.vm.ViewModel
|
||||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
@@ -55,9 +56,11 @@ class AboutViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun checkForUpdates() {
|
fun checkForUpdates() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
toast(MR.strings.update_check_look_for_updates.toPlatformString())
|
||||||
when (val update = updateChecker.await(true, onError = { toast(it.message.orEmpty()) })) {
|
when (val update = updateChecker.await(true, onError = { toast(it.message.orEmpty()) })) {
|
||||||
is Update.UpdateFound -> _updates.emit(update)
|
is Update.UpdateFound -> _updates.emit(update)
|
||||||
else -> Unit
|
is Update.NoUpdatesFound -> toast(MR.strings.update_check_no_new_updates.toPlatformString())
|
||||||
|
null -> Unit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user