aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src
diff options
context:
space:
mode:
authoryxshv <[email protected]>2024-04-13 23:54:22 +0530
committeryxshv <[email protected]>2024-04-13 23:54:22 +0530
commitba47246430be998ba590436852c9744a0da63b65 (patch)
tree15a6c382f63f9f2caae6e89c4c350fec3c551400 /apps/web/src
parentgenerate (diff)
downloadsupermemory-ba47246430be998ba590436852c9744a0da63b65.tar.xz
supermemory-ba47246430be998ba590436852c9744a0da63b65.zip
fix notes
Diffstat (limited to 'apps/web/src')
-rw-r--r--apps/web/src/actions/db.ts19
-rw-r--r--apps/web/src/components/Sidebar/AddMemoryDialog.tsx6
-rw-r--r--apps/web/src/components/Sidebar/FilterCombobox.tsx3
-rw-r--r--apps/web/src/components/Sidebar/MemoriesBar.tsx6
4 files changed, 19 insertions, 15 deletions
diff --git a/apps/web/src/actions/db.ts b/apps/web/src/actions/db.ts
index a7b5bd47..66fbc830 100644
--- a/apps/web/src/actions/db.ts
+++ b/apps/web/src/actions/db.ts
@@ -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
}
diff --git a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx
index 93f4f3a7..90ac46fa 100644
--- a/apps/web/src/components/Sidebar/AddMemoryDialog.tsx
+++ b/apps/web/src/components/Sidebar/AddMemoryDialog.tsx
@@ -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>
)
}
diff --git a/apps/web/src/components/Sidebar/FilterCombobox.tsx b/apps/web/src/components/Sidebar/FilterCombobox.tsx
index 30463672..88bb5a8c 100644
--- a/apps/web/src/components/Sidebar/FilterCombobox.tsx
+++ b/apps/web/src/components/Sidebar/FilterCombobox.tsx
@@ -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}
diff --git a/apps/web/src/components/Sidebar/MemoriesBar.tsx b/apps/web/src/components/Sidebar/MemoriesBar.tsx
index aaf40fd9..1c061451 100644
--- a/apps/web/src/components/Sidebar/MemoriesBar.tsx
+++ b/apps/web/src/components/Sidebar/MemoriesBar.tsx
@@ -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-">