mirror of
https://github.com/linkwarden/linkwarden.git
synced 2026-06-30 15:56:58 +00:00
28 lines
704 B
TypeScript
28 lines
704 B
TypeScript
import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types/global";
|
|
import getFormatBasedOnPreference from "@linkwarden/lib/getFormatBasedOnPreference";
|
|
import { LinksRouteTo } from "@linkwarden/prisma/client";
|
|
|
|
const openLink = (
|
|
link: LinkIncludingShortenedCollectionAndTags,
|
|
user: any,
|
|
openModal: () => void
|
|
) => {
|
|
if (user.linksRouteTo === LinksRouteTo.DETAILS) {
|
|
openModal();
|
|
} else {
|
|
const format = getFormatBasedOnPreference({
|
|
link,
|
|
preference: user.linksRouteTo,
|
|
});
|
|
|
|
window.open(
|
|
format !== null
|
|
? `/preserved/${link?.id}?format=${format}`
|
|
: (link.url as string),
|
|
"_blank"
|
|
);
|
|
}
|
|
};
|
|
|
|
export default openLink;
|