From ee484d8327ff3891d4ffa29527b34753acbd5a17 Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Tue, 3 Oct 2023 12:50:04 -0700 Subject: [PATCH 1/3] ambiguous box check --- src/construct/boxes.py | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/construct/boxes.py b/src/construct/boxes.py index b7c34204..8411e652 100644 --- a/src/construct/boxes.py +++ b/src/construct/boxes.py @@ -27,6 +27,7 @@ class Box: containers: list = field(default_factory=list) syntax: str = None defective: bool = False + ambiguous: bool = False ref: Box = None def __hash__(self): @@ -95,20 +96,30 @@ def get_all_boxes(json_file): def search_box(fourcc, type=None, ref=None): + result = None + matches = 0 for value in BOXES.values(): for _box in value: if type is not None: if _box.fourcc == fourcc and _box.type == type: - return _box + result = _box + matches += 1 else: if _box.fourcc == fourcc: - return _box - - return Box( - fourcc=fourcc, - defective=True, - ref=ref, - ) + result = _box + matches += 1 + + if matches == 1: + return result + if matches > 1: + result.ambiguous = True + return result + if matches == 0: + return Box( + fourcc=fourcc, + defective=True, + ref=ref, + ) def update_container(_spec, _box): @@ -189,6 +200,18 @@ def main(): BOXES[spec] = set() BOXES[spec] = BOXES[spec].union(extensions) + # List ambiguous boxes + buffer = [] + for boxes in BOXES.values(): + for _box in boxes: + if _box.ambiguous and _box.fourcc != "file": + buffer.append(_box.fourcc) + + if len(buffer) > 0: + logger.error( + f"Ambiguous containers found ({len(set(buffer))}): {set(sorted(buffer))}" + ) + # List defective boxes buffer = [] for boxes in BOXES.values(): From 348e00b0a6c1c2f2d3243926dd059faa6c629ced Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Tue, 3 Oct 2023 12:50:26 -0700 Subject: [PATCH 2/3] clear empty filters from query params --- .../src/components/SearchComponent/hooks/useQueryParams.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conformance-search/src/components/SearchComponent/hooks/useQueryParams.ts b/conformance-search/src/components/SearchComponent/hooks/useQueryParams.ts index d4ef1f93..fa175272 100644 --- a/conformance-search/src/components/SearchComponent/hooks/useQueryParams.ts +++ b/conformance-search/src/components/SearchComponent/hooks/useQueryParams.ts @@ -19,6 +19,7 @@ export default function useQueryParams(): [ const encodeFilters = (filters: Filter[]): string => { return filters + .filter((filter) => filter.value !== "") .reduce((acc: string[], filter) => { const { type, value } = filter; return acc.concat([`${type}:${value}`]); @@ -72,7 +73,8 @@ export default function useQueryParams(): [ // Filters rawParams.delete("filters"); - if (filters && filters.length > 0) rawParams.set("filters", encodeFilters(filters)); + if (filters && filters.length > 0 && filters.some((filter) => filter.value !== "")) + rawParams.set("filters", encodeFilters(filters)); const base = window.location.pathname; From 291da8bf9df1e577cdb1cb70c88af27b40184b12 Mon Sep 17 00:00:00 2001 From: DenizUgur Date: Tue, 3 Oct 2023 12:50:51 -0700 Subject: [PATCH 3/3] don't count empty filters as active --- .../SearchComponent/SearchComponent.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/conformance-search/src/components/SearchComponent/SearchComponent.tsx b/conformance-search/src/components/SearchComponent/SearchComponent.tsx index e396f380..dfb09b5e 100644 --- a/conformance-search/src/components/SearchComponent/SearchComponent.tsx +++ b/conformance-search/src/components/SearchComponent/SearchComponent.tsx @@ -20,11 +20,14 @@ export default function SearchComponent({ }) { const [loading, setLoading] = useState(false); const [open, setOpen] = useState(false); - const [filters, { addFilter, removeFilter, updateFilter, resetFilters }] = useFilters(); const [queryParams, setQueryParams] = useQueryParams(); const [query, setQuery] = useState(""); const [ready, setReady] = useState(false); + // Filters + const [filters, { addFilter, removeFilter, updateFilter, resetFilters }] = useFilters(); + const activeFilters = filters.filter((f) => f.value !== ""); + // Load the search state from the URL useEffect(() => { if (queryParams && !ready) { @@ -122,7 +125,8 @@ export default function SearchComponent({ {open && filters.map((filter: Filter, index: number) => (