From b31beebb263719fe5b95b25cea39e77ab9188847 Mon Sep 17 00:00:00 2001 From: Lamberto Basti Date: Tue, 27 Feb 2024 11:22:42 +0100 Subject: [PATCH] Adjust sharing behavior in PackageListViewModel#selectedModulesFlow (#94) --- package-search-api-models | 2 +- .../packagesearch/plugin/ui/PackageSearchPackagePanel.kt | 7 +------ .../plugin/ui/model/packageslist/PackageListViewModel.kt | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/package-search-api-models b/package-search-api-models index aef27525..7e81796c 160000 --- a/package-search-api-models +++ b/package-search-api-models @@ -1 +1 @@ -Subproject commit aef275250b832e73fa12ce9ce94a7b242d925468 +Subproject commit 7e81796c95d0b6a6943fa89378ae5b1d0cf6a688 diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/PackageSearchPackagePanel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/PackageSearchPackagePanel.kt index f87fcb7c..460ac918 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/PackageSearchPackagePanel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/PackageSearchPackagePanel.kt @@ -3,10 +3,8 @@ package com.jetbrains.packagesearch.plugin.ui import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import com.intellij.ui.JBColor import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule import com.jetbrains.packagesearch.plugin.ui.bridge.packageSearchSplitter import com.jetbrains.packagesearch.plugin.ui.model.ToolWindowViewModel @@ -15,8 +13,6 @@ import com.jetbrains.packagesearch.plugin.ui.panels.packages.PackageSearchCentra import com.jetbrains.packagesearch.plugin.ui.panels.side.PackageSearchInfoPanel import com.jetbrains.packagesearch.plugin.ui.panels.tree.PackageSearchModulesTree import org.jetbrains.compose.splitpane.HorizontalSplitPane -import org.jetbrains.jewel.bridge.toComposeColor -import org.jetbrains.jewel.foundation.theme.JewelTheme @Composable fun PackageSearchPackagePanel( @@ -25,11 +21,10 @@ fun PackageSearchPackagePanel( onLinkClick: (String) -> Unit, onPackageEvent: (PackageListItemEvent) -> Unit, ) { - val toolWindowsViewModel = viewModel() + val toolWindowsViewModel: ToolWindowViewModel = viewModel() val splitPaneState by remember { toolWindowsViewModel.firstSplitPaneState } val innerSplitPaneState by remember { toolWindowsViewModel.secondSplitPaneState } - val splitterColor by remember(JewelTheme.isDark) { mutableStateOf(JBColor.border().toComposeColor()) } HorizontalSplitPane(Modifier.fillMaxSize(), splitPaneState) { first(PackageSearchMetrics.Splitpane.minWidth) { diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt index 6591e3ab..aa0ecbd3 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt @@ -98,7 +98,7 @@ class PackageListViewModel( ) { selectedModules, modulesByIdentity -> modulesByIdentity.filterKeys { it in selectedModules }.values.toList() } - .shareIn(viewModelScope, SharingStarted.Lazily) + .shareIn(viewModelScope, SharingStarted.Lazily, 1) private val searchQueryMutableStateFlow = MutableStateFlow("") val searchQueryStateFlow = searchQueryMutableStateFlow.asStateFlow()