Fix extension settings icon trying to install update instead of opening details

This commit is contained in:
arkon 2023-12-31 23:46:07 -05:00
parent 83130f9bf9
commit b5e3f429fc
2 changed files with 16 additions and 10 deletions

View File

@ -71,7 +71,7 @@ fun ExtensionScreen(
searchQuery: String?, searchQuery: String?,
onLongClickItem: (Extension) -> Unit, onLongClickItem: (Extension) -> Unit,
onClickItemCancel: (Extension) -> Unit, onClickItemCancel: (Extension) -> Unit,
onClickItemWebView: (Extension.Available) -> Unit, onOpenWebView: (Extension.Available) -> Unit,
onInstallExtension: (Extension.Available) -> Unit, onInstallExtension: (Extension.Available) -> Unit,
onUninstallExtension: (Extension) -> Unit, onUninstallExtension: (Extension) -> Unit,
onUpdateExtension: (Extension.Installed) -> Unit, onUpdateExtension: (Extension.Installed) -> Unit,
@ -104,7 +104,7 @@ fun ExtensionScreen(
contentPadding = contentPadding, contentPadding = contentPadding,
onLongClickItem = onLongClickItem, onLongClickItem = onLongClickItem,
onClickItemCancel = onClickItemCancel, onClickItemCancel = onClickItemCancel,
onClickItemWebView = onClickItemWebView, onOpenWebView = onOpenWebView,
onInstallExtension = onInstallExtension, onInstallExtension = onInstallExtension,
onUninstallExtension = onUninstallExtension, onUninstallExtension = onUninstallExtension,
onUpdateExtension = onUpdateExtension, onUpdateExtension = onUpdateExtension,
@ -122,8 +122,8 @@ private fun ExtensionContent(
state: ExtensionsScreenModel.State, state: ExtensionsScreenModel.State,
contentPadding: PaddingValues, contentPadding: PaddingValues,
onLongClickItem: (Extension) -> Unit, onLongClickItem: (Extension) -> Unit,
onClickItemWebView: (Extension.Available) -> Unit,
onClickItemCancel: (Extension) -> Unit, onClickItemCancel: (Extension) -> Unit,
onOpenWebView: (Extension.Available) -> Unit,
onInstallExtension: (Extension.Available) -> Unit, onInstallExtension: (Extension.Available) -> Unit,
onUninstallExtension: (Extension) -> Unit, onUninstallExtension: (Extension) -> Unit,
onUpdateExtension: (Extension.Installed) -> Unit, onUpdateExtension: (Extension.Installed) -> Unit,
@ -202,7 +202,13 @@ private fun ExtensionContent(
} }
}, },
onLongClickItem = onLongClickItem, onLongClickItem = onLongClickItem,
onClickItemWebView = onClickItemWebView, onClickItemSecondaryAction = {
when (it) {
is Extension.Available -> onOpenWebView(it)
is Extension.Installed -> onOpenExtension(it)
else -> {}
}
},
onClickItemCancel = onClickItemCancel, onClickItemCancel = onClickItemCancel,
onClickItemAction = { onClickItemAction = {
when (it) { when (it) {
@ -243,9 +249,9 @@ private fun ExtensionItem(
item: ExtensionUiModel.Item, item: ExtensionUiModel.Item,
onClickItem: (Extension) -> Unit, onClickItem: (Extension) -> Unit,
onLongClickItem: (Extension) -> Unit, onLongClickItem: (Extension) -> Unit,
onClickItemWebView: (Extension.Available) -> Unit,
onClickItemCancel: (Extension) -> Unit, onClickItemCancel: (Extension) -> Unit,
onClickItemAction: (Extension) -> Unit, onClickItemAction: (Extension) -> Unit,
onClickItemSecondaryAction: (Extension) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
val (extension, installStep) = item val (extension, installStep) = item
@ -287,9 +293,9 @@ private fun ExtensionItem(
ExtensionItemActions( ExtensionItemActions(
extension = extension, extension = extension,
installStep = installStep, installStep = installStep,
onClickItemWebView = onClickItemWebView,
onClickItemCancel = onClickItemCancel, onClickItemCancel = onClickItemCancel,
onClickItemAction = onClickItemAction, onClickItemAction = onClickItemAction,
onClickItemSecondaryAction = onClickItemSecondaryAction,
) )
}, },
) { ) {
@ -371,9 +377,9 @@ private fun ExtensionItemActions(
extension: Extension, extension: Extension,
installStep: InstallStep, installStep: InstallStep,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onClickItemWebView: (Extension.Available) -> Unit = {},
onClickItemCancel: (Extension) -> Unit = {}, onClickItemCancel: (Extension) -> Unit = {},
onClickItemAction: (Extension) -> Unit = {}, onClickItemAction: (Extension) -> Unit = {},
onClickItemSecondaryAction: (Extension) -> Unit = {},
) { ) {
val isIdle = installStep.isCompleted() val isIdle = installStep.isCompleted()
@ -401,7 +407,7 @@ private fun ExtensionItemActions(
installStep == InstallStep.Idle -> { installStep == InstallStep.Idle -> {
when (extension) { when (extension) {
is Extension.Installed -> { is Extension.Installed -> {
IconButton(onClick = { onClickItemAction(extension) }) { IconButton(onClick = { onClickItemSecondaryAction(extension) }) {
Icon( Icon(
imageVector = Icons.Outlined.Settings, imageVector = Icons.Outlined.Settings,
contentDescription = stringResource(MR.strings.action_settings), contentDescription = stringResource(MR.strings.action_settings),
@ -428,7 +434,7 @@ private fun ExtensionItemActions(
is Extension.Available -> { is Extension.Available -> {
if (extension.sources.isNotEmpty()) { if (extension.sources.isNotEmpty()) {
IconButton( IconButton(
onClick = { onClickItemWebView(extension) }, onClick = { onClickItemSecondaryAction(extension) },
) { ) {
Icon( Icon(
imageVector = Icons.Outlined.Public, imageVector = Icons.Outlined.Public,

View File

@ -48,7 +48,7 @@ fun extensionsTab(
}, },
onClickItemCancel = extensionsScreenModel::cancelInstallUpdateExtension, onClickItemCancel = extensionsScreenModel::cancelInstallUpdateExtension,
onClickUpdateAll = extensionsScreenModel::updateAllExtensions, onClickUpdateAll = extensionsScreenModel::updateAllExtensions,
onClickItemWebView = { extension -> onOpenWebView = { extension ->
extension.sources.getOrNull(0)?.let { extension.sources.getOrNull(0)?.let {
navigator.push( navigator.push(
WebViewScreen( WebViewScreen(