⚡️⚡️⚡️ 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
remove pending format logic
daniel31x13625904843120
diff --git a/components/LinkDetails.tsx b/components/LinkDetails.tsxindex 44950892..0a98cf9b 100644--- a/components/LinkDetails.tsx+++ b/components/LinkDetails.tsx@@ -96,17 +96,10 @@ export default function LinkDetails({const isReady = () => {return (link &&- (collectionOwner.archiveAsScreenshot === true- ? link.pdf && link.pdf !== "pending"- : true) &&- (collectionOwner.archiveAsMonolith === true- ? link.monolith && link.monolith !== "pending"- : true) &&- (collectionOwner.archiveAsPDF === true- ? link.pdf && link.pdf !== "pending"- : true) &&- link.readable &&- link.readable !== "pending"+ (collectionOwner.archiveAsScreenshot === true ? link.pdf : true) &&+ (collectionOwner.archiveAsMonolith === true ? link.monolith : true) &&+ (collectionOwner.archiveAsPDF === true ? link.pdf : true) &&+ link.readable);};diff --git a/components/ReadableView.tsx b/components/ReadableView.tsxindex 1bc35769..6c36b65b 100644--- a/components/ReadableView.tsx+++ b/components/ReadableView.tsx@@ -70,14 +70,7 @@ export default function ReadableView({ link }: Props) {let interval: NodeJS.Timeout | null = null;if (link &&- (link?.image === "pending" ||- link?.pdf === "pending" ||- link?.readable === "pending" ||- link?.monolith === "pending" ||- !link?.image ||- !link?.pdf ||- !link?.readable ||- !link?.monolith)+ (!link?.image || !link?.pdf || !link?.readable || !link?.monolith)) {interval = setInterval(() =>@@ -261,7 +254,7 @@ export default function ReadableView({ link }: Props) {) : (<divclassName={`w-full h-full flex flex-col justify-center p-10 ${- link?.readable === "pending" || !link?.readable ? "skeleton" : ""+ !link?.readable ? "skeleton" : ""}`}><svgdiff --git a/lib/api/archiveHandler.ts b/lib/api/archiveHandler.tsindex e54ad654..696b93fb 100644--- a/lib/api/archiveHandler.ts+++ b/lib/api/archiveHandler.ts@@ -100,24 +100,6 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {where: { id: link.id },data: {type: linkType,- image:- user.archiveAsScreenshot && !link.image?.startsWith("archive")- ? "pending"- : undefined,- pdf:- user.archiveAsPDF && !link.pdf?.startsWith("archive")- ? "pending"- : undefined,- monolith:- user.archiveAsMonolith && !link.monolith?.startsWith("archive")- ? "pending"- : undefined,- readable: !link.readable?.startsWith("archive")- ? "pending"- : undefined,- preview: !link.readable?.startsWith("archive")- ? "pending"- : undefined,lastPreserved: new Date().toISOString(),},});diff --git a/lib/shared/getArchiveValidity.ts b/lib/shared/getArchiveValidity.tsindex 8e55db84..0c937140 100644--- a/lib/shared/getArchiveValidity.ts+++ b/lib/shared/getArchiveValidity.ts@@ -5,12 +5,7 @@ export function formatAvailable(link: Link | LinkIncludingShortenedCollectionAndTags,format: "image" | "pdf" | "readable" | "monolith" | "preview") {- return (- link &&- link[format] &&- link[format] !== "pending" &&- link[format] !== "unavailable"- );+ return link && link[format] && link[format] !== "unavailable";}export function formatStatus(@@ -25,8 +20,6 @@ export function formatStatus(link[format].startsWith("archive")) {return "processed";- } else if (link[format].startsWith("pending")) {- return "pending";} else {return "error";}diff --git a/prisma/migrations/20241209210046_remove_pending_fields/migration.sql b/prisma/migrations/20241209210046_remove_pending_fields/migration.sqlnew file mode 100644index 00000000..57b99208--- /dev/null+++ b/prisma/migrations/20241209210046_remove_pending_fields/migration.sql@@ -0,0 +1,5 @@+UPDATE "Link" SET "pdf" = NULL WHERE "pdf" = 'pending';+UPDATE "Link" SET "monolith" = NULL WHERE "monolith" = 'pending';+UPDATE "Link" SET "readable" = NULL WHERE "readable" = 'pending';+UPDATE "Link" SET "image" = NULL WHERE "image" = 'pending';+UPDATE "Link" SET "preview" = NULL WHERE "preview" = 'pending';\ No newline at end of filediff --git a/scripts/worker.ts b/scripts/worker.tsindex f5142393..4ed234b6 100644--- a/scripts/worker.ts+++ b/scripts/worker.ts@@ -21,31 +21,15 @@ async function processBatch() {{image: null,},- {- image: "pending",- },- ///////////////////////{pdf: null,},- {- pdf: "pending",- },- ///////////////////////{readable: null,},- {- readable: "pending",- },- ///////////////////////{monolith: null,},- {- monolith: "pending",- },- ///////////////////////{// See if tags are emptycollection: {@@ -77,31 +61,15 @@ async function processBatch() {{image: null,},- {- image: "pending",- },- ///////////////////////{pdf: null,},- {- pdf: "pending",- },- ///////////////////////{readable: null,},- {- readable: "pending",- },- ///////////////////////{monolith: null,},- {- monolith: "pending",- },- ///////////////////////{// See if tags are emptycollection: {