mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Ensure a Callback and only one is provided in the Plugin. Also reduce boilerplate code in Nodes.
This commit is contained in:
committed by
Benoit Marty
parent
2e8785b36b
commit
be03c50aaf
+3
-6
@@ -12,12 +12,12 @@ import androidx.compose.ui.Modifier
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
import com.bumble.appyx.core.plugin.plugins
|
||||
import dev.zacsweers.metro.AppScope
|
||||
import dev.zacsweers.metro.Assisted
|
||||
import dev.zacsweers.metro.AssistedInject
|
||||
import io.element.android.annotations.ContributesNode
|
||||
import io.element.android.features.licenses.impl.model.DependencyLicenseItem
|
||||
import io.element.android.libraries.architecture.callback
|
||||
|
||||
@ContributesNode(AppScope::class)
|
||||
@AssistedInject
|
||||
@@ -33,10 +33,7 @@ class DependencyLicensesListNode(
|
||||
fun navigateToLicense(license: DependencyLicenseItem)
|
||||
}
|
||||
|
||||
private fun onOpenLicense(license: DependencyLicenseItem) {
|
||||
plugins<Callback>()
|
||||
.forEach { it.navigateToLicense(license) }
|
||||
}
|
||||
private val callback: Callback = callback()
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
@@ -44,7 +41,7 @@ class DependencyLicensesListNode(
|
||||
DependencyLicensesListView(
|
||||
state = state,
|
||||
onBackClick = ::navigateUp,
|
||||
onOpenLicense = ::onOpenLicense,
|
||||
onOpenLicense = callback::navigateToLicense,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user