mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Plugin update appToast, Refs
This commit is contained in:
parent
0dc33e1f2b
commit
0f60d4737e
2 changed files with 16 additions and 7 deletions
|
@ -568,14 +568,23 @@ class StateApp {
|
|||
StateAnnouncement.instance.deleteAnnouncement("plugin-update")
|
||||
|
||||
scopeOrNull?.launch(Dispatchers.IO) {
|
||||
val updateAvailableCount = StatePlatform.instance.checkForUpdates()
|
||||
val updateAvailable = StatePlatform.instance.checkForUpdates()
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
if (updateAvailableCount > 0) {
|
||||
if (updateAvailable.isNotEmpty()) {
|
||||
UIDialogs.appToast(
|
||||
ToastView.Toast(updateAvailable
|
||||
.map { " - " + it.name }
|
||||
.joinToString("\n"),
|
||||
true,
|
||||
null,
|
||||
"Plugin updates available"
|
||||
));
|
||||
|
||||
StateAnnouncement.instance.registerAnnouncement(
|
||||
"plugin-update",
|
||||
"Plugin updates available",
|
||||
"There are $updateAvailableCount plugin updates available.",
|
||||
"There are ${updateAvailable.size} plugin updates available.",
|
||||
AnnouncementType.SESSION_RECURRING
|
||||
)
|
||||
}
|
||||
|
|
|
@ -941,8 +941,8 @@ class StatePlatform {
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun checkForUpdates(): Int = withContext(Dispatchers.IO) {
|
||||
var updateAvailableCount = 0
|
||||
suspend fun checkForUpdates(): List<SourcePluginConfig> = withContext(Dispatchers.IO) {
|
||||
var configs = mutableListOf<SourcePluginConfig>()
|
||||
val updatesAvailableFor = hashSetOf<String>()
|
||||
for (availableClient in getAvailableClients()) {
|
||||
if (availableClient !is JSClient) {
|
||||
|
@ -950,13 +950,13 @@ class StatePlatform {
|
|||
}
|
||||
|
||||
if (checkForUpdates(availableClient.config)) {
|
||||
updateAvailableCount++
|
||||
configs.add(availableClient.config);
|
||||
updatesAvailableFor.add(availableClient.config.id)
|
||||
}
|
||||
}
|
||||
|
||||
_updatesAvailableMap = updatesAvailableFor
|
||||
return@withContext updateAvailableCount
|
||||
return@withContext configs;
|
||||
}
|
||||
|
||||
fun clearUpdateAvailable(c: SourcePluginConfig) {
|
||||
|
|
Loading…
Add table
Reference in a new issue