⚡️⚡️⚡️ 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
minor improvements
daniel31x132bacf6e07da1
diff --git a/components/InputSelect/TagSelection.tsx b/components/InputSelect/TagSelection.tsxindex 6917abae..46042030 100644--- a/components/InputSelect/TagSelection.tsx+++ b/components/InputSelect/TagSelection.tsx@@ -39,36 +39,19 @@ export default function TagSelection({}, [tags]);return (- <>- {isArchivalSelection ? (- <CreatableSelect- isClearable={false}- className="react-select-container"- classNamePrefix="react-select"- onChange={onChange}- options={options}- styles={styles}- value={[]}- placeholder={t("tag_selection_placeholder")}- isMulti- autoFocus={autoFocus}- onBlur={onBlur}- />- ) : (- <CreatableSelect- isClearable={false}- className="react-select-container"- classNamePrefix="react-select"- onChange={onChange}- options={tagOptions}- styles={styles}- defaultValue={defaultValue}- placeholder={t("tag_selection_placeholder")}- isMulti- autoFocus={autoFocus}- onBlur={onBlur}- />- )}- </>+ <CreatableSelect+ isClearable={false}+ className="react-select-container"+ classNamePrefix="react-select"+ onChange={onChange}+ options={isArchivalSelection ? options : tagOptions}+ styles={styles}+ value={isArchivalSelection ? [] : undefined}+ defaultValue={isArchivalSelection ? undefined : defaultValue}+ placeholder={t("tag_selection_placeholder")}+ isMulti+ autoFocus={autoFocus}+ onBlur={onBlur}+ />);}diff --git a/hooks/useArchivalTags.ts b/hooks/useArchivalTags.tsindex 5bb16dad..c4b1499a 100644--- a/hooks/useArchivalTags.ts+++ b/hooks/useArchivalTags.ts@@ -5,14 +5,7 @@ import {} from "../components/InputSelect/types";import { useState, useEffect } from "react";import { useTranslation } from "react-i18next";--export const isArchivalTag = (tag: ArchivalTagOption | Tag) =>- typeof tag.archiveAsScreenshot === "boolean" ||- typeof tag.archiveAsMonolith === "boolean" ||- typeof tag.archiveAsPDF === "boolean" ||- typeof tag.archiveAsReadable === "boolean" ||- typeof tag.archiveAsWaybackMachine === "boolean" ||- typeof tag.aiTag === "boolean";+import isArchivalTag from "@/lib/shared/isArchivalTag";const useArchivalTags = (initialTags: Tag[]) => {const [archivalTags, setArchivalTags] = useState<ArchivalTagOption[]>([]);diff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.tsindex 922b4f4e..daf9d759 100644--- a/lib/api/archiveHandler.ts+++ b/lib/api/archiveHandler.ts@@ -13,7 +13,7 @@ import imageHandler from "./preservationScheme/imageHandler";import pdfHandler from "./preservationScheme/pdfHandler";import autoTagLink from "./autoTagLink";import { LinkWithCollectionOwnerAndTags } from "../../types/global";-import { isArchivalTag } from "../../hooks/useArchivalTags";+import isArchivalTag from "../shared/isArchivalTag";const BROWSER_TIMEOUT = Number(process.env.BROWSER_TIMEOUT) || 5;diff --git a/lib/shared/isArchivalTag.ts b/lib/shared/isArchivalTag.tsnew file mode 100644index 00000000..0963fefb--- /dev/null+++ b/lib/shared/isArchivalTag.ts@@ -0,0 +1,12 @@+import { Tag } from "@prisma/client";+import { ArchivalTagOption } from "../../components/InputSelect/types";++const isArchivalTag = (tag: ArchivalTagOption | Tag) =>+ typeof tag.archiveAsScreenshot === "boolean" ||+ typeof tag.archiveAsMonolith === "boolean" ||+ typeof tag.archiveAsPDF === "boolean" ||+ typeof tag.archiveAsReadable === "boolean" ||+ typeof tag.archiveAsWaybackMachine === "boolean" ||+ typeof tag.aiTag === "boolean";++export default isArchivalTag;diff --git a/lib/shared/schemaValidation.ts b/lib/shared/schemaValidation.tsindex cf7184fd..5c046840 100644--- a/lib/shared/schemaValidation.ts+++ b/lib/shared/schemaValidation.ts@@ -228,7 +228,7 @@ export const PostRssSubscriptionSchema = z.object({export const PostTagSchema = z.object({tags: z.array(z.object({- label: z.string(),+ label: z.string().trim().max(50),archiveAsScreenshot: z.boolean().nullish(),archiveAsMonolith: z.boolean().nullish(),archiveAsPDF: z.boolean().nullish(),@@ -245,7 +245,6 @@ export const LinkArchiveActionSchema = z.object({action: z.enum(["allAndRePreserve", "allAndIgnore", "allBroken"]),});-export type LinkArchiveActionSchemaType =- | "allAndRePreserve"- | "allAndIgnore"- | "allBroken";+export type LinkArchiveActionSchemaType = z.infer<+ typeof LinkArchiveActionSchema+>["action"];diff --git a/pages/api/v1/links/archive/index.ts b/pages/api/v1/links/archive/index.tsindex 07ffe02c..bedf5eda 100644--- a/pages/api/v1/links/archive/index.ts+++ b/pages/api/v1/links/archive/index.ts@@ -6,8 +6,8 @@ import {removeFiles,removePreservationFiles,} from "@/lib/api/manageLinkFiles";-import { isArchivalTag } from "@/hooks/useArchivalTags";import { ArchivalSettings } from "@/lib/api/archiveHandler";+import isArchivalTag from "@/lib/shared/isArchivalTag";export default async function links(req: NextApiRequest, res: NextApiResponse) {const user = await verifyUser({ req, res });@@ -30,7 +30,6 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {}const { action } = dataValidation.data;- let count = 0;if (action === "allAndIgnore") {const allLinks = await prisma.link.findMany();@@ -63,10 +62,9 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {preview: null,},});- count++;}- return res.status(200).json({ count });+ return res.status(200).json({ response: "Success." });} else if (action === "allBroken") {const brokenArchives = await prisma.link.findMany({where: {@@ -152,11 +150,10 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {: link.monolith,},});- count++;}}- return res.status(200).json({ count });+ return res.status(200).json({ response: "Success." });}}}diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsxindex 512f51fd..dcdc5ba3 100644--- a/pages/settings/preference.tsx+++ b/pages/settings/preference.tsx@@ -12,7 +12,8 @@ import { useConfig } from "@/hooks/store/config";import { useTags, useUpdateArchivalTags } from "@/hooks/store/tags";import { cn } from "@/lib/client/utils";import TagSelection from "@/components/InputSelect/TagSelection";-import { isArchivalTag, useArchivalTags } from "@/hooks/useArchivalTags";+import { useArchivalTags } from "@/hooks/useArchivalTags";+import isArchivalTag from "@/lib/shared/isArchivalTag";export default function Preference() {const { t } = useTranslation();diff --git a/pages/settings/worker.tsx b/pages/settings/worker.tsxindex 62997325..3d18e5a1 100644--- a/pages/settings/worker.tsx+++ b/pages/settings/worker.tsx@@ -63,15 +63,7 @@ export default function Worker() {if (action === "allAndIgnore") {toast.success(t("deleted"));} else {- if (data.count === 0) {- toast.success(t("no_broken_preservations"));- } else if (data.count === 1) {- toast.success(t("successfully_represerved_link"));- } else {- toast.success(- t("successfully_represerved_links", { count: data.count })- );- }+ toast.success(t("links_are_being_represerved"));}}},diff --git a/public/locales/en/common.json b/public/locales/en/common.jsonindex bf1aff3f..1819da9f 100644--- a/public/locales/en/common.json+++ b/public/locales/en/common.json@@ -464,21 +464,15 @@"search_query_invalid_symbol": "The search query should not contain '%'.","open_modal_new_tab": "Open this modal in a new tab","file": "File",- "write_new_note": "Write a New Note",- "new_note": "New Note",- "add_a_title_placeholder": "Add a title...",- "write_notes_here_placeholder": "Write some notes here...","archival_tag_settings": "Tag archival settings:","archival_tag_info": "Applying archival tags to a link will override the global archival settings.","ai_tagging": "AI Tagging","worker": "Worker",- "regenerate_broken_preservations": "Regenerate all broken or missing preservations.",- "delete_all_preservations": "Delete preservation for all webpages.",- "delete_all_preservations_and_regenerate": "Delete preservation for all webpages and re-preserve.",- "delete_all_preservation_warning": "This action will delete all existing preservations.",+ "regenerate_broken_preservations": "Regenerate all broken or missing preservations for all users.",+ "delete_all_preservations": "Delete preservation for all webpages, applies to all users.",+ "delete_all_preservations_and_regenerate": "Delete preservation for all webpages and re-preserve, applies to all users.",+ "delete_all_preservation_warning": "This action will delete all existing preservations on the server.","no_broken_preservations": "No broken preservations.",- "successfully_represerved_link": "Successfully re-preserved 1 link.",- "successfully_represerved_links": "Successfully re-preserved {{count}} links.",+ "links_are_being_represerved": "Links are being re-preserved...","cancel": "Cancel"-}\ No newline at end of file