Fix issues when updating extensions

This commit is contained in:
AntsyLich 2024-01-22 02:27:45 +06:00
parent 39407407f2
commit cb06898430
No known key found for this signature in database
3 changed files with 12 additions and 3 deletions

View File

@ -203,7 +203,13 @@ private fun ExtensionContent(
items( items(
items = items, items = items,
contentType = { "item" }, contentType = { "item" },
key = { "extension-${it.hashCode()}" }, key = { item ->
when (item.extension) {
is Extension.Untrusted -> "extension-untrusted-${item.hashCode()}"
is Extension.Installed -> "extension-installed-${item.hashCode()}"
is Extension.Available -> "extension-available-${item.hashCode()}"
}
},
) { item -> ) { item ->
ExtensionItem( ExtensionItem(
modifier = Modifier.animateItemPlacement(), modifier = Modifier.animateItemPlacement(),

View File

@ -338,6 +338,10 @@ class ExtensionManager(
} }
override fun onExtensionUntrusted(extension: Extension.Untrusted) { override fun onExtensionUntrusted(extension: Extension.Untrusted) {
val installedExtension = _installedExtensionsFlow.value
.find { it.pkgName == extension.pkgName }
?: return
_installedExtensionsFlow.value -= installedExtension
_untrustedExtensionsFlow.value += extension _untrustedExtensionsFlow.value += extension
} }

View File

@ -70,8 +70,7 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
launchNow { launchNow {
when (val result = getExtensionFromIntent(context, intent)) { when (val result = getExtensionFromIntent(context, intent)) {
is LoadResult.Success -> listener.onExtensionUpdated(result.extension) is LoadResult.Success -> listener.onExtensionUpdated(result.extension)
// Not needed as a package can't be upgraded if the signature is different is LoadResult.Untrusted -> listener.onExtensionUntrusted(result.extension)
// is LoadResult.Untrusted -> {}
else -> {} else -> {}
} }
} }