diff --git a/app/src/main/kotlin/dev/sanmer/mrepo/ui/screens/repository/view/ViewTopBar.kt b/app/src/main/kotlin/dev/sanmer/mrepo/ui/screens/repository/view/ViewTopBar.kt index a072d45a..bb0f1ed3 100644 --- a/app/src/main/kotlin/dev/sanmer/mrepo/ui/screens/repository/view/ViewTopBar.kt +++ b/app/src/main/kotlin/dev/sanmer/mrepo/ui/screens/repository/view/ViewTopBar.kt @@ -78,10 +78,10 @@ private fun TopBarContent( val userPreferences = LocalUserPreferences.current val repositoryMenu = userPreferences.repositoryMenu - val hasLicense by remember { + val hasLicense by remember(module.metadata) { derivedStateOf { module.metadata.license.isNotBlank() } } - val hasDonate by remember { + val hasDonate by remember(module.metadata) { derivedStateOf { module.metadata.donate.isNotBlank() } } diff --git a/app/src/main/kotlin/dev/sanmer/mrepo/viewmodel/ModuleViewModel.kt b/app/src/main/kotlin/dev/sanmer/mrepo/viewmodel/ModuleViewModel.kt index cd643a28..69675813 100644 --- a/app/src/main/kotlin/dev/sanmer/mrepo/viewmodel/ModuleViewModel.kt +++ b/app/src/main/kotlin/dev/sanmer/mrepo/viewmodel/ModuleViewModel.kt @@ -49,18 +49,21 @@ class ModuleViewModel @Inject constructor( var local: LocalModule? by mutableStateOf(null) private set + val localVersionCode by lazy { + if (notifyUpdates && installed) local!!.versionCode else Int.MAX_VALUE + } - private val installed get() = local?.let { it.author == online.author } ?: false var notifyUpdates by mutableStateOf(false) private set + private val installed by lazy { + local?.let { it.author == online.author } ?: false + } - val localVersionCode get() = - if (notifyUpdates && installed) local!!.versionCode else Int.MAX_VALUE + val versions = mutableStateListOf>() val updatableSize by derivedStateOf { versions.count { it.second.versionCode > localVersionCode } } - val versions = mutableStateListOf>() init { Timber.d("ModuleViewModel init: $moduleId")