⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
bugs fixed
daniel31x13ea8673783503
diff --git a/components/FilterSearchDropdown.tsx b/components/FilterSearchDropdown.tsxindex 2c835ab2..181febbb 100644--- a/components/FilterSearchDropdown.tsx+++ b/components/FilterSearchDropdown.tsx@@ -1,12 +1,16 @@import React, { SetStateAction } from "react";import ClickAwayHandler from "./ClickAwayHandler";import Checkbox from "./Checkbox";-import { LinkSearchFilter } from "@/types/global";type Props = {setFilterDropdown: (value: SetStateAction<boolean>) => void;setSearchFilter: Function;- searchFilter: LinkSearchFilter;+ searchFilter: {+ name: boolean;+ url: boolean;+ description: boolean;+ tags: boolean;+ };};export default function FilterSearchDropdown({diff --git a/components/Modal/Link/AddOrEditLink.tsx b/components/Modal/Link/AddOrEditLink.tsxindex dcdf4223..201b3d00 100644--- a/components/Modal/Link/AddOrEditLink.tsx+++ b/components/Modal/Link/AddOrEditLink.tsx@@ -46,6 +46,8 @@ export default function AddOrEditLink({url: "",description: "",tags: [],+ screenshotPath: "",+ pdfPath: "",collection: {name: "",ownerId: data?.user.id as number,diff --git a/lib/api/controllers/migration/exportData.ts b/lib/api/controllers/migration/exportData.tsindex 49a25b42..2776d851 100644--- a/lib/api/controllers/migration/exportData.ts+++ b/lib/api/controllers/migration/exportData.ts@@ -18,7 +18,7 @@ export default async function exportData(userId: number) {if (!user) return { response: "User not found.", status: 404 };- const { password, id, image, ...userData } = user;+ const { password, id, ...userData } = user;function redactIds(obj: any) {if (Array.isArray(obj)) {diff --git a/lib/api/migration/migrateToV2.js b/lib/api/migration/migrateToV2.jsindex aeb07fbe..29c7e178 100644--- a/lib/api/migration/migrateToV2.js+++ b/lib/api/migration/migrateToV2.js@@ -1,83 +1,124 @@+const { S3 } = require("@aws-sdk/client-s3");const { PrismaClient } = require("@prisma/client");const axios = require("axios");const { existsSync } = require("fs");+const util = require("util");const prisma = new PrismaClient();const STORAGE_FOLDER = process.env.STORAGE_FOLDER || "data";+const s3Client =+ process.env.SPACES_ENDPOINT &&+ process.env.SPACES_REGION &&+ process.env.SPACES_KEY &&+ process.env.SPACES_SECRET+ ? new S3({+ forcePathStyle: false,+ endpoint: process.env.SPACES_ENDPOINT,+ region: process.env.SPACES_REGION,+ credentials: {+ accessKeyId: process.env.SPACES_KEY,+ secretAccessKey: process.env.SPACES_SECRET,+ },+ })+ : undefined;+async function checkFileExistence(path) {- try {- if (existsSync(path)) {- return true;- } else return false;- } catch (err) {- console.log(err);+ if (s3Client) {+ const bucketParams = {+ Bucket: process.env.BUCKET_NAME,+ Key: path,+ };++ console.log(path);+ try {+ const headObjectAsync = util.promisify(+ s3Client.headObject.bind(s3Client)+ );++ try {+ await headObjectAsync(bucketParams);+ return true;+ } catch (err) {+ return false;+ }+ } catch (err) {+ console.log("Error:", err);++ return false;+ }+ } else {+ try {+ if (existsSync(STORAGE_FOLDER + "/" + path)) {+ return true;+ } else return false;+ } catch (err) {+ console.log(err);+ }}}// Avatars-async function migrateAvatars() {+async function migrateToV2() {const users = await prisma.user.findMany();for (let user of users) {- const path = STORAGE_FOLDER + `/uploads/avatar/${user.id}.jpg`;+ const path = `uploads/avatar/${user.id}.jpg`;const res = await checkFileExistence(path);if (res) {- // await prisma.user.update({- // where: { id: user.id },- // data: { image: "avatar/" + user.id },- // });- console.log(`Updated avatar for user ${user.id}`);+ await prisma.user.update({+ where: { id: user.id },+ data: { imagePath: path },+ });+ console.log(`Updated avatar for avatar ${user.id}`);} else {- console.log(`No avatar found for user ${user.id}`);+ console.log(`No avatar found for avatar ${user.id}`);}}const links = await prisma.link.findMany();- // Screenshots+ // PDFsfor (let link of links) {- const path =- STORAGE_FOLDER + `/archives/${link.collectionId}/${link.id}.pdf`;+ const path = `archives/${link.collectionId}/${link.id}.pdf`;const res = await checkFileExistence(path);if (res) {- // await prisma.user.update({- // where: { id: user.id },- // data: { image: "avatar/" + user.id },- // });- console.log(`Updated capture for link ${link.id}`);+ await prisma.link.update({+ where: { id: link.id },+ data: { pdfPath: path },+ });+ console.log(`Updated capture for pdf ${link.id}`);} else {- console.log(`No capture found for link ${link.id}`);+ console.log(`No capture found for pdf ${link.id}`);}}- // PDFs+ // Screenshotsfor (let link of links) {- const path =- STORAGE_FOLDER + `/archives/${link.collectionId}/${link.id}.png`;+ const path = `archives/${link.collectionId}/${link.id}.png`;const res = await checkFileExistence(path);if (res) {- // await prisma.user.update({- // where: { id: user.id },- // data: { image: "avatar/" + user.id },- // });- console.log(`Updated capture for link ${link.id}`);+ await prisma.link.update({+ where: { id: link.id },+ data: { screenshotPath: path },+ });+ console.log(`Updated capture for screenshot ${link.id}`);} else {- console.log(`No capture found for link ${link.id}`);+ console.log(`No capture found for screenshot ${link.id}`);}}await prisma.$disconnect();}-migrateAvatars().catch((e) => {+migrateToV2().catch((e) => {console.error(e);process.exit(1);});diff --git a/pages/api/v1/getToken.ts b/pages/api/v1/getToken.tsindex c767075d..e51c4bbb 100644--- a/pages/api/v1/getToken.ts+++ b/pages/api/v1/getToken.ts@@ -14,3 +14,5 @@// }// res.end();// };++export {};diff --git a/pages/collections/index.tsx b/pages/collections/index.tsxindex 0df05886..1f812859 100644--- a/pages/collections/index.tsx+++ b/pages/collections/index.tsx@@ -154,7 +154,7 @@ export default function Collections() {</p><p className="capitalize text-black dark:text-white">- Shared collections you're a member of+ Shared collections you're a member of</p></div></div>diff --git a/pages/settings/delete.tsx b/pages/settings/delete.tsxindex e072ab1f..6a293af6 100644--- a/pages/settings/delete.tsx+++ b/pages/settings/delete.tsx@@ -119,7 +119,8 @@ export default function Password() {</label><div><p className="text-sm mb-2 text-black dark:text-white">- More information (the more details, the more helpful it'd be)+ More information (the more details, the more helpful it'd+ be)</p><textarea