⚡️⚡️⚡️ 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
format
Isaac Wise47b226cf1f9e
diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsxindex 20ff0844..6b83f275 100644--- a/components/InputSelect/CollectionSelection.tsx+++ b/components/InputSelect/CollectionSelection.tsx@@ -11,11 +11,11 @@ type Props = {onChange: any;showDefaultValue?: boolean;defaultValue?:- | {- label: string;- value?: number;- }- | undefined;+ | {+ label: string;+ value?: number;+ }+ | undefined;creatable?: boolean;autoFocus?: boolean;onBlur?: any;@@ -29,7 +29,7 @@ export default function CollectionSelection({creatable = true,autoFocus,onBlur,- className+ className,}: Props) {const { data: collections = [] } = useCollections();@@ -117,7 +117,7 @@ export default function CollectionSelection({components={{Option: customOption,}}- // menuPosition="fixed"+ // menuPosition="fixed"/>);} else {@@ -135,7 +135,7 @@ export default function CollectionSelection({components={{Option: customOption,}}- // menuPosition="fixed"+ // menuPosition="fixed"/>);}diff --git a/components/ModalContent/NewRssSubscriptionModal.tsx b/components/ModalContent/NewRssSubscriptionModal.tsxindex 0b87b261..45df8065 100644--- a/components/ModalContent/NewRssSubscriptionModal.tsx+++ b/components/ModalContent/NewRssSubscriptionModal.tsx@@ -7,92 +7,92 @@ import TextInput from "../TextInput";import CollectionSelection from "../InputSelect/CollectionSelection";type Props = {- onClose: Function;+ onClose: Function;};export default function NewRssSubscriptionModal({ onClose }: Props) {- const { t } = useTranslation();- const addRssSubscription = useAddRssSubscription();- const [submitLoader, setSubmitLoader] = useState(false);+ const { t } = useTranslation();+ const addRssSubscription = useAddRssSubscription();+ const [submitLoader, setSubmitLoader] = useState(false);- const [form, setForm] = useState({- name: "",- url: "",- collectionId: 0,- collectionName: ""- });+ const [form, setForm] = useState({+ name: "",+ url: "",+ collectionId: 0,+ collectionName: "",+ });- const submit = async () => {- if (submitLoader) return;+ const submit = async () => {+ if (submitLoader) return;- setSubmitLoader(true);+ setSubmitLoader(true);- const load = toast.loading(t("creating"));+ const load = toast.loading(t("creating"));- await addRssSubscription.mutateAsync(form, {- onSettled: (_, error) => {- setSubmitLoader(false);- toast.dismiss(load);+ await addRssSubscription.mutateAsync(form, {+ onSettled: (_, error) => {+ setSubmitLoader(false);+ toast.dismiss(load);- if (error) {- toast.error(error.message);- } else {- onClose();- toast.success(t("created"));- }- },- });- }+ if (error) {+ toast.error(error.message);+ } else {+ onClose();+ toast.success(t("created"));+ }+ },+ });+ };- return (- <Modal toggleModal={onClose}>- <>- <p className="text-xl font-thin">{t("create_rss_subscription")}</p>+ return (+ <Modal toggleModal={onClose}>+ <>+ <p className="text-xl font-thin">{t("create_rss_subscription")}</p>- <div className="divider mb-3 mt-1"></div>- <div className="flex sm:flex-row flex-col gap-3 items-center">- <div className="w-full">- <label>{t("name")}</label>- <TextInput- type="text"- className="bg-base-200 mt-2"- value={form.name}- onChange={(e) => setForm({ ...form, name: e.target.value })}- />- </div>- <div className="w-full">- <label>{t("link")}</label>- <TextInput- type="text"- className="bg-base-200 mt-2"- value={form.url}- onChange={(e) => setForm({ ...form, url: e.target.value })}- />- </div>- </div>- <div className="w-full mt-3">- <label>{t("collection")}</label>- <CollectionSelection- className="mt-2"- onChange={(e: any) => {- if (e?.__isNew__) e.value = undefined;- setForm({- ...form,- collectionId: e?.value,- collectionName: e?.label,- });- }}- />- </div>- <div className="flex justify-end items-center mt-5">- <button- className="btn btn-accent dark:border-violet-400 text-white"- onClick={submit}- >- {t("create_token")}- </button>- </div>- </>- </Modal>- );+ <div className="divider mb-3 mt-1"></div>+ <div className="flex sm:flex-row flex-col gap-3 items-center">+ <div className="w-full">+ <label>{t("name")}</label>+ <TextInput+ type="text"+ className="bg-base-200 mt-2"+ value={form.name}+ onChange={(e) => setForm({ ...form, name: e.target.value })}+ />+ </div>+ <div className="w-full">+ <label>{t("link")}</label>+ <TextInput+ type="text"+ className="bg-base-200 mt-2"+ value={form.url}+ onChange={(e) => setForm({ ...form, url: e.target.value })}+ />+ </div>+ </div>+ <div className="w-full mt-3">+ <label>{t("collection")}</label>+ <CollectionSelection+ className="mt-2"+ onChange={(e: any) => {+ if (e?.__isNew__) e.value = undefined;+ setForm({+ ...form,+ collectionId: e?.value,+ collectionName: e?.label,+ });+ }}+ />+ </div>+ <div className="flex justify-end items-center mt-5">+ <button+ className="btn btn-accent dark:border-violet-400 text-white"+ onClick={submit}+ >+ {t("create_token")}+ </button>+ </div>+ </>+ </Modal>+ );}diff --git a/lib/api/controllers/links/postLink.ts b/lib/api/controllers/links/postLink.tsindex 5b0b0059..830ac324 100644--- a/lib/api/controllers/links/postLink.ts+++ b/lib/api/controllers/links/postLink.ts@@ -17,8 +17,9 @@ export default async function postLink(if (!dataValidation.success) {return {- response: `Error: ${dataValidation.error.issues[0].message- } [${dataValidation.error.issues[0].path.join(", ")}]`,+ response: `Error: ${+ dataValidation.error.issues[0].message+ } [${dataValidation.error.issues[0].path.join(", ")}]`,status: 400,};}diff --git a/lib/api/setCollection.ts b/lib/api/setCollection.tsindex a7b34ec9..094786d0 100644--- a/lib/api/setCollection.ts+++ b/lib/api/setCollection.ts@@ -8,7 +8,11 @@ type SetCollectionInput = {collectionName?: string;};-const setCollection = async ({ userId, collectionId, collectionName }: SetCollectionInput) => {+const setCollection = async ({+ userId,+ collectionId,+ collectionName,+}: SetCollectionInput) => {if (collectionId) {// Check if the collection existsconst existingCollection = await prisma.collection.findUnique({@@ -37,15 +41,17 @@ const setCollection = async ({ userId, collectionId, collectionName }: SetCollecif (collectionName) {// If the collection name is "Unorganized", find or create itif (collectionName === "Unorganized") {- const firstTopLevelUnorganizedCollection = await prisma.collection.findFirst({- where: {- name: "Unorganized",- ownerId: userId,- parentId: null,- },- });-- if (firstTopLevelUnorganizedCollection) return firstTopLevelUnorganizedCollection;+ const firstTopLevelUnorganizedCollection =+ await prisma.collection.findFirst({+ where: {+ name: "Unorganized",+ ownerId: userId,+ parentId: null,+ },+ });++ if (firstTopLevelUnorganizedCollection)+ return firstTopLevelUnorganizedCollection;}// Create a new collection with the given namediff --git a/lib/shared/schemaValidation.ts b/lib/shared/schemaValidation.tsindex a3949488..7cc94853 100644--- a/lib/shared/schemaValidation.ts+++ b/lib/shared/schemaValidation.ts@@ -41,12 +41,12 @@ export const PostUserSchema = () => {username: emailEnabled? z.string().optional(): z- .string()- .trim()- .toLowerCase()- .min(3)- .max(50)- .regex(/^[a-z0-9_-]{3,50}$/),+ .string()+ .trim()+ .toLowerCase()+ .min(3)+ .max(50)+ .regex(/^[a-z0-9_-]{3,50}$/),invite: z.boolean().optional(),});};@@ -216,4 +216,3 @@ export const PostRssSubscriptionSchema = z.object({collectionId: z.number().optional(),collectionName: z.string().optional(),});-diff --git a/pages/api/v1/user/rss/index.ts b/pages/api/v1/user/rss/index.tsindex 88ad2223..05a676f9 100644--- a/pages/api/v1/user/rss/index.ts+++ b/pages/api/v1/user/rss/index.ts@@ -32,8 +32,9 @@ export default async function handler(if (!dataValidation.success) {return res.status(400).json({- response: `Error: ${dataValidation.error.issues[0].message- } [${dataValidation.error.issues[0].path.join(", ")}]`,+ response: `Error: ${+ dataValidation.error.issues[0].message+ } [${dataValidation.error.issues[0].path.join(", ")}]`,});}@@ -46,12 +47,9 @@ export default async function handler(});if (!linkCollection) {- return res- .status(403)- .json({- response:- "You do not have permission to add a link to this collection",- });+ return res.status(403).json({+ response: "You do not have permission to add a link to this collection",+ });}const existingRssSubscription = await prisma.rssSubscription.findFirst({diff --git a/pages/settings/rss-subscriptions.tsx b/pages/settings/rss-subscriptions.tsxindex f6eb8282..e47d1ea5 100644--- a/pages/settings/rss-subscriptions.tsx+++ b/pages/settings/rss-subscriptions.tsx@@ -79,7 +79,9 @@ export default function RssSubscriptions() {)}</div>{newSubscriptionModal && (- <NewRssSubscriptionModal onClose={() => setNewSubscriptionModal(false)} />+ <NewRssSubscriptionModal+ onClose={() => setNewSubscriptionModal(false)}+ />)}{deleteSubscriptionModal && selectedSubscription && (<DeleteRssSubscriptionModaldiff --git a/scripts/worker.ts b/scripts/worker.tsindex 9ca91c8a..121ad48c 100644--- a/scripts/worker.ts+++ b/scripts/worker.ts@@ -148,7 +148,10 @@ async function fetchAndProcessRSS() {rssSubscription.lastBuildDate &&new Date(rssSubscription.lastBuildDate) < new Date(feed.lastBuildDate)) {- console.log("\x1b[34m%s\x1b[0m", `Processing new RSS feed items for ${rssSubscription.name}`);+ console.log(+ "\x1b[34m%s\x1b[0m",+ `Processing new RSS feed items for ${rssSubscription.name}`+ );const newItems = feed.items.filter((item) => {const itemPubDate = item.pubDate ? new Date(item.pubDate) : null;