Skip to content

Commit

Permalink
Fix issues when updating extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
AntsyLich committed Jan 21, 2024
1 parent 3940740 commit cb06898
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,13 @@ private fun ExtensionContent(
items(
items = items,
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 ->
ExtensionItem(
modifier = Modifier.animateItemPlacement(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ class ExtensionManager(
}

override fun onExtensionUntrusted(extension: Extension.Untrusted) {
val installedExtension = _installedExtensionsFlow.value
.find { it.pkgName == extension.pkgName }
?: return
_installedExtensionsFlow.value -= installedExtension
_untrustedExtensionsFlow.value += extension
}

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

0 comments on commit cb06898

Please sign in to comment.