Allow users to choose what clicking links opens
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 || '';
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user