mirror of
https://github.com/open-webui/open-webui
synced 2025-06-10 16:38:21 +00:00
refac
This commit is contained in:
parent
5d7c89964c
commit
fc5dfd3536
@ -36,16 +36,17 @@ def get_sorted_filter_ids(request, model: dict, enabled_filter_ids: list = None)
|
|||||||
function.id
|
function.id
|
||||||
for function in Functions.get_functions_by_type("filter", active_only=True)
|
for function in Functions.get_functions_by_type("filter", active_only=True)
|
||||||
]
|
]
|
||||||
|
|
||||||
def should_keep_filter(filter_id):
|
def get_active_status(filter_id):
|
||||||
function_module = get_function_module(request, filter_id)
|
function_module = get_function_module(request, filter_id)
|
||||||
|
|
||||||
return not (getattr(function_module, "toggle", None) and
|
if getattr(function_module, "toggle", None):
|
||||||
filter_id not in (enabled_filter_ids or []))
|
return filter_id in (enabled_filter_ids or [])
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
active_filter_ids = [
|
active_filter_ids = [
|
||||||
filter_id for filter_id in active_filter_ids
|
filter_id for filter_id in active_filter_ids if get_active_status(filter_id)
|
||||||
if should_keep_filter(filter_id)
|
|
||||||
]
|
]
|
||||||
|
|
||||||
filter_ids = [fid for fid in filter_ids if fid in active_filter_ids]
|
filter_ids = [fid for fid in filter_ids if fid in active_filter_ids]
|
||||||
|
Loading…
Reference in New Issue
Block a user