fix notes

This commit is contained in:
yxshv 2024-04-13 23:54:22 +05:30
parent 13cc8d8c5b
commit ba47246430
6 changed files with 25 additions and 16 deletions

5
apps/web/public/note.svg Normal file
View file

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#6F6F6F" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-text w-10 h-10">
<path d="M17 6.1H3"></path>
<path d="M21 12.1H3">
</path><path d="M15.1 18H3"></path>
</svg>

After

Width:  |  Height:  |  Size: 310 B

View file

@ -1,3 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418" />
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 677 B

View file

@ -31,7 +31,7 @@ export async function searchMemoriesAndSpaces(query: string, opts?: { filter?: {
}).from(storedContent).where(and(
eq(storedContent.user, user.id),
like(storedContent.title, `%${query}%`)
));
)).orderBy(asc(storedContent.savedAt));
const searchSpacesQuery = db.select({
type: sql<string>`'space'`,
@ -42,10 +42,12 @@ export async function searchMemoriesAndSpaces(query: string, opts?: { filter?: {
eq(space.user, user.id),
like(space.name, `%${query}%`)
)
);
).orderBy(asc(space.name));
let queries = [];
console.log('adding');
[undefined, true].includes(opts?.filter?.memories) && queries.push(searchMemoriesQuery);
[undefined, true].includes(opts?.filter?.spaces) && queries.push(searchSpacesQuery);
@ -56,6 +58,8 @@ export async function searchMemoriesAndSpaces(query: string, opts?: { filter?: {
}
const data = await Promise.all(queries)
console.log('resp', data)
return data.reduce((acc, i) => [...acc, ...i]) as SearchResult[]
} catch {
@ -231,12 +235,13 @@ export async function deleteSpace(id: number) {
return null
}
await db.delete(contentToSpace)
.where(eq(contentToSpace.spaceId, id));
const [deleted] = await db.delete(space)
.where(and(eq(space.user, user.id), eq(space.id, id)))
.returning();
await db.delete(contentToSpace)
.where(eq(contentToSpace.spaceId, id));
return deleted
@ -252,13 +257,13 @@ export async function deleteMemory(id: number) {
return null
}
await db.delete(contentToSpace)
.where(eq(contentToSpace.contentId, id));
const [deleted] = await db.delete(storedContent)
.where(and(eq(storedContent.user, user.id), eq(storedContent.id, id)))
.returning();
await db.delete(contentToSpace)
.where(eq(contentToSpace.contentId, id));
return deleted
}

View file

@ -313,15 +313,15 @@ export function SpaceAddPage({ closeDialog }: { closeDialog: () => void }) {
);
}
export function MemorySelectedItem({ id, title, url, image, onRemove }: StoredContent & { onRemove: () => void; }) {
export function MemorySelectedItem({ id, title, url, type, image, onRemove }: StoredContent & { onRemove: () => void; }) {
return (
<div className="flex justify-start gap-2 p-1 px-2 w-full items-center text-sm rounded-md hover:bg-rgray-4 focus-within-bg-rgray-4 [&:hover>[data-icon]]:block [&:hover>img]:hidden">
<img src={image ?? "/icons/logo_without_bg.png"} className="h-5 w-5" />
<img src={type === 'note'? '/note.svg' : image ?? "/icons/logo_without_bg.png"} className="h-5 w-5" />
<button onClick={onRemove} data-icon className="w-5 h-5 p-0 m-0 hidden focus-visible:outline-none">
<X className="w-5 h-5 scale-90" />
</button>
<span>{title}</span>
<span className="ml-auto block opacity-50">{cleanUrl(url)}</span>
<span className="ml-auto block opacity-50">{type ==='note' ? 'Note' : cleanUrl(url)}</span>
</div>
)
}

View file

@ -180,7 +180,6 @@ export function FilterMemories({
const [isSearching, setIsSearching] = React.useState(false)
const results = React.useMemo(() => {
console.log("use memo")
return searchResults.map(r => r.memory)
}, [searchResults])
@ -258,7 +257,7 @@ export function FilterMemories({
<div
className="text-rgray-11"
>
<img src={m.image ?? "/icons/logo_without_bg.png"} className="mr-2 h-4 w-4" />
<img src={m.type === 'note' ? '/note.svg' : m.image ?? "/icons/logo_without_bg.png"} className="mr-2 h-4 w-4" />
{m.title}
<Check
data-state-on={selected.find(i => i.id === m.id) !== undefined}

View file

@ -354,19 +354,19 @@ export function SpaceItem({
<MemoryWithImages3
className="h-24 w-24"
id={id.toString()}
images={spaceMemories.map((c) => c.image).reverse() as string[]}
images={spaceMemories.map((c) => c.type === 'note' ? '/note.svg' : c.image).reverse() as string[]}
/>
) : spaceMemories.length > 1 ? (
<MemoryWithImages2
className="h-24 w-24"
id={id.toString()}
images={spaceMemories.map((c) => c.image).reverse() as string[]}
images={spaceMemories.map((c) => c.type === 'note' ? '/note.svg' : c.image).reverse() as string[]}
/>
) : spaceMemories.length === 1 ? (
<MemoryWithImage
className="h-24 w-24"
id={id.toString()}
image={spaceMemories[0].image!}
image={spaceMemories[0].type === 'note' ? '/note.svg' : spaceMemories[0].image!}
/>
) : (
<div className="bg-rgray-4 opacity-30 rounded-full w-24 h-24 scale-50 shadow-">