fix: make notImported studio filter work independently of import status
This commit is contained in:
1 parent
4b7cb519df
commit
92b0ba3b18
1 file changed
+12
-7
@@ -151,17 +151,16 @@ export function StudioClient({
|
||||
result = result.filter((i) => i.category === categoryFilter);
|
||||
}
|
||||
if (statusFilter !== "all") {
|
||||
if (statusFilter === "new")
|
||||
result = result.filter((i) => !i.alreadyImported);
|
||||
else if (statusFilter === "imported")
|
||||
if (statusFilter === "imported")
|
||||
result = result.filter((i) => i.alreadyImported);
|
||||
else if (statusFilter === "inCatalog")
|
||||
result = result.filter((i) => i.alreadyImported && i.nitroExists);
|
||||
else if (statusFilter === "missingNitro")
|
||||
result = result.filter((i) => i.alreadyImported && !i.nitroExists);
|
||||
else if (statusFilter === "notImported")
|
||||
result = result.filter((i) => !i.alreadyImported);
|
||||
}
|
||||
// Not imported filter - works independently (also with statusFilter === "all")
|
||||
if (statusFilter === "notImported" || statusFilter === "all")
|
||||
result = result.filter((i) => i.alreadyImported === false);
|
||||
const sorted = [...result];
|
||||
if (sortBy === "name") sorted.sort((a, b) => a.name.localeCompare(b.name));
|
||||
else if (sortBy === "classname")
|
||||
@@ -597,6 +596,11 @@ export function StudioClient({
|
||||
[filteredItems],
|
||||
);
|
||||
|
||||
const notImportedCount = useMemo(
|
||||
() => filteredItems.filter((i) => i.alreadyImported === false).length,
|
||||
[filteredItems],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex h-[calc(100dvh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-[var(--admin-border)]"
|
||||
@@ -741,8 +745,9 @@ export function StudioClient({
|
||||
<SelectValue placeholder="Status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All statuses</SelectItem>
|
||||
<SelectItem value="new">Not imported</SelectItem>
|
||||
<SelectItem value="all">
|
||||
All statuses {notImportedCount > 0 && notImportedCount}
|
||||
</SelectItem>
|
||||
<SelectItem value="imported">Imported</SelectItem>
|
||||
<SelectItem value="inCatalog">In catalog</SelectItem>
|
||||
<SelectItem value="missingNitro">Missing nitro</SelectItem>
|
||||
|
||||
Reference in new issue
Block a user