aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2024-09-20 20:39:10 -0700
committerGitHub <[email protected]>2024-09-20 20:39:10 -0700
commitde028754ab41f1428be87792a9309f84c8591303 (patch)
tree40b01cdae24d0c9da01a875980a2e77236b4ceba
parentfix: extension on top (diff)
parentfix: duplicate content saving data in extension (diff)
downloadsupermemory-de028754ab41f1428be87792a9309f84c8591303.tar.xz
supermemory-de028754ab41f1428be87792a9309f84c8591303.zip
Merge pull request #295 from supermemoryai/extension/duplicate-save-fix
fix: duplicate content saving data in extension
-rw-r--r--apps/web/app/api/store/helper.ts53
1 files changed, 0 insertions, 53 deletions
diff --git a/apps/web/app/api/store/helper.ts b/apps/web/app/api/store/helper.ts
index 17794a0b..4e0fa0c8 100644
--- a/apps/web/app/api/store/helper.ts
+++ b/apps/web/app/api/store/helper.ts
@@ -50,59 +50,6 @@ export const createMemoryFromAPI = async (input: {
let contentId: number;
- const saveToDbUrl =
- (input.data.url.split("#supermemory-user-")[0] ?? input.data.url) +
- "#supermemory-user-" +
- input.userId;
-
- const noteId = new Date().getTime();
-
- // Insert into database
- try {
- const insertResponse = await db
- .insert(storedContent)
- .values({
- content: input.data.pageContent,
- title: input.data.title,
- description: input.data.description,
- url: saveToDbUrl,
- baseUrl: saveToDbUrl,
- image: input.data.image,
- savedAt: new Date(),
- userId: input.userId,
- type: input.data.type,
- noteId,
- })
- .returning({ id: storedContent.id });
-
- if (!insertResponse[0]?.id) {
- return {
- success: false,
- data: 0,
- error: "Failed to save to database",
- };
- }
-
- contentId = insertResponse[0].id;
- } catch (e) {
- const error = e as Error;
- console.log("Error: ", error.message);
-
- if (error.message.includes("D1_ERROR: UNIQUE constraint failed:")) {
- return {
- success: false,
- data: 0,
- error: "Content already exists",
- };
- }
-
- return {
- success: false,
- data: 0,
- error: "Failed to save to database with error: " + error.message,
- };
- }
-
if (input.data.spaces.length > 0) {
// Adding the many-to-many relationship between content and spaces
const spaceData = await db