This commit is contained in:
Daniel 2023-07-05 10:43:37 +03:30
parent 9af7bab1db
commit 818b04b781
3 changed files with 15 additions and 38 deletions

View File

@ -9,7 +9,6 @@ type Props = {
name: boolean; name: boolean;
url: boolean; url: boolean;
description: boolean; description: boolean;
collection: boolean;
tags: boolean; tags: boolean;
}; };
}; };
@ -53,16 +52,6 @@ export default function FilterSearchDropdown({
}) })
} }
/> />
<Checkbox
label="Collection"
state={searchFilter.collection}
onClick={() =>
setSearchFilter({
...searchFilter,
collection: !searchFilter.collection,
})
}
/>
<Checkbox <Checkbox
label="Tags" label="Tags"
state={searchFilter.tags} state={searchFilter.tags}

View File

@ -41,6 +41,21 @@ export default async function getLink(userId: number, body: string) {
} }
: undefined, : undefined,
where: { where: {
collection: {
id: query.collectionId ? query.collectionId : undefined, // If collectionId was defined, filter by collection
OR: [
{
ownerId: userId,
},
{
members: {
some: {
userId,
},
},
},
],
},
[query.searchQuery ? "OR" : "AND"]: [ [query.searchQuery ? "OR" : "AND"]: [
{ {
pinnedBy: query.pinnedOnly ? { some: { id: userId } } : undefined, pinnedBy: query.pinnedOnly ? { some: { id: userId } } : undefined,
@ -72,32 +87,6 @@ export default async function getLink(userId: number, body: string) {
mode: "insensitive", mode: "insensitive",
}, },
}, },
{
collection: {
id: query.collectionId ? query.collectionId : undefined, // If collectionId was defined, filter by collection
name:
query.searchQuery && query.searchFilter?.collection
? {
contains: query.searchQuery,
mode: "insensitive",
}
: undefined,
OR: query.searchQuery
? undefined
: [
{
ownerId: userId,
},
{
members: {
some: {
userId,
},
},
},
],
},
},
{ {
tags: tags:
query.searchQuery && !query.searchFilter?.tags query.searchQuery && !query.searchFilter?.tags

View File

@ -60,7 +60,6 @@ export type LinkSearchFilter = {
name: boolean; name: boolean;
url: boolean; url: boolean;
description: boolean; description: boolean;
collection: boolean;
tags: boolean; tags: boolean;
}; };