@@ -102,8 +100,8 @@ export default function LinkCardCompact({
collection={collection}
position="top-3 right-3"
flipDropdown={flipDropdown}
- // toggleShowInfo={() => setShowInfo(!showInfo)}
- // linkInfo={showInfo}
+ // toggleShowInfo={() => setShowInfo(!showInfo)}
+ // linkInfo={showInfo}
/>
{showInfo ? (
diff --git a/lib/api/controllers/users/userId/updateUserById.ts b/lib/api/controllers/users/userId/updateUserById.ts
index 285e44e5..162f2460 100644
--- a/lib/api/controllers/users/userId/updateUserById.ts
+++ b/lib/api/controllers/users/userId/updateUserById.ts
@@ -97,18 +97,18 @@ export default async function updateUserById(
id: { not: userId },
OR: emailEnabled
? [
- {
- username: data.username.toLowerCase(),
- },
- {
- email: data.email?.toLowerCase(),
- },
- ]
+ {
+ username: data.username.toLowerCase(),
+ },
+ {
+ email: data.email?.toLowerCase(),
+ },
+ ]
: [
- {
- username: data.username.toLowerCase(),
- },
- ],
+ {
+ username: data.username.toLowerCase(),
+ },
+ ],
},
});
@@ -186,6 +186,7 @@ export default async function updateUserById(
archiveAsScreenshot: data.archiveAsScreenshot,
archiveAsPDF: data.archiveAsPDF,
archiveAsWaybackMachine: data.archiveAsWaybackMachine,
+ linksRouteTo: data.linksRouteTo,
password:
data.newPassword && data.newPassword !== ""
? newHashedPassword
diff --git a/lib/client/generateHrefBasedOnUserPreference .ts b/lib/client/generateHrefBasedOnUserPreference .ts
new file mode 100644
index 00000000..10ef13bd
--- /dev/null
+++ b/lib/client/generateHrefBasedOnUserPreference .ts
@@ -0,0 +1,20 @@
+import useAccountStore from "@/store/account";
+import { ArchivedFormat, LinkIncludingShortenedCollectionAndTags } from "@/types/global";
+import { LinksRouteTo } from "@prisma/client";
+
+export const generateLinkHrefBasedOnUserPreference = (link: LinkIncludingShortenedCollectionAndTags): string => {
+ const { account } = useAccountStore();
+
+ switch (account.linksRouteTo) {
+ case LinksRouteTo.ORIGINAL:
+ return link.url || '';
+ case LinksRouteTo.PDF:
+ return `/preserved/${link?.id}?format=${ArchivedFormat.pdf}`;
+ case LinksRouteTo.READABLE:
+ return `/preserved/${link?.id}?format=${ArchivedFormat.readability}`;
+ case LinksRouteTo.SCREENSHOT:
+ return `/preserved/${link?.id}?format=${link?.image?.endsWith("png") ? ArchivedFormat.png : ArchivedFormat.jpeg}`;
+ default:
+ return link.url || '';
+ }
+};
\ No newline at end of file
diff --git a/pages/settings/preference.tsx b/pages/settings/preference.tsx
index ed6cc02c..a92f6aed 100644
--- a/pages/settings/preference.tsx
+++ b/pages/settings/preference.tsx
@@ -7,6 +7,7 @@ import React from "react";
import useLocalSettingsStore from "@/store/localSettings";
import Checkbox from "@/components/Checkbox";
import SubmitButton from "@/components/SubmitButton";
+import { LinksRouteTo } from "@prisma/client";
export default function Appearance() {
const { updateSettings } = useLocalSettingsStore();
@@ -20,6 +21,7 @@ export default function Appearance() {
const [archiveAsPDF, setArchiveAsPDF] = useState
(false);
const [archiveAsWaybackMachine, setArchiveAsWaybackMachine] =
useState(false);
+ const [linksRouteTo, setLinksRouteTo] = useState(user.linksRouteTo);
useEffect(() => {
setUser({
@@ -27,8 +29,9 @@ export default function Appearance() {
archiveAsScreenshot,
archiveAsPDF,
archiveAsWaybackMachine,
+ linksRouteTo
});
- }, [account, archiveAsScreenshot, archiveAsPDF, archiveAsWaybackMachine]);
+ }, [account, archiveAsScreenshot, archiveAsPDF, archiveAsWaybackMachine, linksRouteTo]);
function objectIsEmpty(obj: object) {
return Object.keys(obj).length === 0;
@@ -39,6 +42,7 @@ export default function Appearance() {
setArchiveAsScreenshot(account.archiveAsScreenshot);
setArchiveAsPDF(account.archiveAsPDF);
setArchiveAsWaybackMachine(account.archiveAsWaybackMachine);
+ setLinksRouteTo(account.linksRouteTo);
}
}, [account]);
@@ -70,11 +74,10 @@ export default function Appearance() {
Select Theme
updateSettings({ theme: "dark" })}
>
@@ -83,11 +86,10 @@ export default function Appearance() {
{/*
*/}
updateSettings({ theme: "light" })}
>
@@ -133,7 +135,32 @@ export default function Appearance() {
-
Clicking on Links should:
+
Clicking on Links should open:
+
+ setLinksRouteTo(LinksRouteTo.ORIGINAL)}
+ />
+
+ setLinksRouteTo(LinksRouteTo.PDF)}
+ />
+
+ setLinksRouteTo(LinksRouteTo.READABLE)}
+ />
+
+ setLinksRouteTo(LinksRouteTo.SCREENSHOT)}
+ />
+