diff --git a/dont_fret/web/bursts/components.py b/dont_fret/web/bursts/components.py index 66cd65b..ca9f562 100644 --- a/dont_fret/web/bursts/components.py +++ b/dont_fret/web/bursts/components.py @@ -17,7 +17,7 @@ from dont_fret.web.components import FigureFromTask, RangeInputField, RegexSelectDialog from dont_fret.web.methods import chain_filters from dont_fret.web.models import BinnedImage, BurstFilterItem, BurstNode, BurstPlotSettings -from dont_fret.web.new_models import FRETNode, FRETStore, ListStore +from dont_fret.web.new_models import FRETNode, FRETStore, ListStore, use_liststore from dont_fret.web.utils import ( NestedSelectors, find_index, @@ -190,10 +190,7 @@ def FilterEditDialog(): existing_filter_fields = [f.name for f in state.filters] selector_nodes = make_selector_nodes(state.fret_nodes.items, attr="bursts") - def make_store(): - return ListStore[str]([selector_nodes[0].value, selector_nodes[0].children[0].value]) - - burst_node_choice = solara.use_memo(make_store, []) + burst_node_choice = use_liststore([]) def make_chart(): burst_node = get_bursts(state.fret_nodes.items, burst_node_choice.items) diff --git a/dont_fret/web/new_models.py b/dont_fret/web/new_models.py index f35d3a1..32980e9 100644 --- a/dont_fret/web/new_models.py +++ b/dont_fret/web/new_models.py @@ -114,6 +114,14 @@ def index(self, item: T) -> int: return self.items.index(item) +def use_liststore(initial_value: list[T]) -> ListStore[T]: + def make_liststore(): + return ListStore(initial_value) + + store = solara.use_memo(make_liststore, []) + return store + + @dataclasses.dataclass class FRETNode: name: solara.Reactive[str] # displayed name