Skip to content

Commit

Permalink
Adjust sharing behavior in PackageListViewModel#selectedModulesFlow (#94
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lamba92 authored Feb 27, 2024
1 parent b5a00c2 commit b31beeb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand All @@ -25,11 +21,10 @@ fun PackageSearchPackagePanel(
onLinkClick: (String) -> Unit,
onPackageEvent: (PackageListItemEvent) -> Unit,
) {
val toolWindowsViewModel = viewModel<ToolWindowViewModel>()
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b31beeb

Please sign in to comment.