mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
address selection filter review feedback
This commit is contained in:
@@ -18,6 +18,21 @@ debug('Trace: PASTE')
|
||||
warn_once_set = WeakSet()
|
||||
|
||||
|
||||
def filter_ui_choices(choices: list[str], preferences: list[str] | None = None, selected: str | None = None) -> tuple[list[str], bool]:
|
||||
"""Return display choices while preserving the current selection."""
|
||||
available = list(dict.fromkeys(choices))
|
||||
preferred = set(preferences or [])
|
||||
filtered = [choice for choice in available if choice in preferred]
|
||||
if not filtered:
|
||||
return available, False
|
||||
if selected in available and selected not in filtered:
|
||||
filtered.append(selected)
|
||||
if 'None' in filtered:
|
||||
filtered.remove('None')
|
||||
filtered.insert(0, 'None')
|
||||
return filtered, len(filtered) < len(available)
|
||||
|
||||
|
||||
def gr_show(visible=True):
|
||||
return {"visible": visible, "__type__": "update"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user