diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsx index 6f2d6cd..3ee9050 100644 --- a/components/LinkViews/LinkCard.tsx +++ b/components/LinkViews/LinkCard.tsx @@ -34,6 +34,12 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) { const { links, getLink, setSelectedLinks, selectedLinks } = useLinkStore(); + useEffect(() => { + if (!editMode) { + setSelectedLinks([]); + } + }, [editMode]); + const handleCheckboxClick = ( link: LinkIncludingShortenedCollectionAndTags ) => { @@ -103,6 +109,7 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) { editMode && (permissions === true || permissions?.canCreate || permissions?.canDelete); + // window.open ('www.yourdomain.com', '_ blank'); return (
- {!editMode ? ( - <> - -
- {previewAvailable(link) ? ( - { - const target = e.target as HTMLElement; - target.style.display = "none"; - }} - /> - ) : link.preview === "unavailable" ? ( -
- ) : ( -
- )} -
- -
-
- -
- -
-

- {unescapeString(link.name || link.description) || link.url} -

- -
-
- -

{shortendURL}

-
-
-
- -
- -
-
- {collection && ( - - )} -
- -
- - - {showInfo && ( -
-
setShowInfo(!showInfo)} - className=" float-right btn btn-sm outline-none btn-circle btn-ghost z-10" - > - -
-

Description

- -
-

- {link.description ? ( - unescapeString(link.description) - ) : ( - - No description provided. - - )} -

- {link.tags[0] && ( - <> -

- Tags -

- -
- -
-
- {link.tags.map((e, i) => ( - { - e.stopPropagation(); - }} - className="btn btn-xs btn-ghost truncate max-w-[19rem]" - > - #{e.name} - - ))} -
-
- - )} -
+
+ !editMode && window.open(generateLinkHref(link, account), "_blank") + } + > +
+ {previewAvailable(link) ? ( + { + const target = e.target as HTMLElement; + target.style.display = "none"; + }} + /> + ) : link.preview === "unavailable" ? ( +
+ ) : ( +
)} +
+ +
+
- setShowInfo(!showInfo)} - linkInfo={showInfo} - flipDropdown={flipDropdown} - /> - - ) : ( - <> -
-
- {previewAvailable(link) ? ( - { - const target = e.target as HTMLElement; - target.style.display = "none"; - }} - /> - ) : link.preview === "unavailable" ? ( -
- ) : ( -
- )} -
- -
-
+
-
+
+

+ {unescapeString(link.name || link.description) || link.url} +

-
-

- {unescapeString(link.name || link.description) || link.url} -

- -
-
- -

{shortendURL}

-
-
-
- -
- -
-
- {collection && ( - - )} -
- +
+
+ +

{shortendURL}

+
- {showInfo && ( -
-
setShowInfo(!showInfo)} - className=" float-right btn btn-sm outline-none btn-circle btn-ghost z-10" - > - -
-

Description

+
+ +
+
+ {collection && ( + + )} +
+ +
+
+ + {showInfo && ( +
+
setShowInfo(!showInfo)} + className=" float-right btn btn-sm outline-none btn-circle btn-ghost z-10" + > + +
+

Description

+ +
+

+ {link.description ? ( + unescapeString(link.description) + ) : ( + + No description provided. + + )} +

+ {link.tags[0] && ( + <> +

Tags


-

- {link.description ? ( - unescapeString(link.description) - ) : ( - - No description provided. - - )} -

- {link.tags[0] && ( - <> -

- Tags -

-
- -
-
- {link.tags.map((e, i) => ( - { - e.stopPropagation(); - }} - className="btn btn-xs btn-ghost truncate max-w-[19rem]" - > - #{e.name} - - ))} -
-
- - )} -
+
+
+ {link.tags.map((e, i) => ( + { + e.stopPropagation(); + }} + className="btn btn-xs btn-ghost truncate max-w-[19rem]" + > + #{e.name} + + ))} +
+
+ )} - - setShowInfo(!showInfo)} - linkInfo={showInfo} - flipDropdown={flipDropdown} - /> - +
)} + + setShowInfo(!showInfo)} + linkInfo={showInfo} + flipDropdown={flipDropdown} + />
); } diff --git a/components/LinkViews/LinkList.tsx b/components/LinkViews/LinkList.tsx index bc91bd0..89d26cd 100644 --- a/components/LinkViews/LinkList.tsx +++ b/components/LinkViews/LinkList.tsx @@ -34,6 +34,12 @@ export default function LinkCardCompact({ const { account } = useAccountStore(); const { links, setSelectedLinks, selectedLinks } = useLinkStore(); + useEffect(() => { + if (!editMode) { + setSelectedLinks([]); + } + }, [editMode]); + const handleCheckboxClick = ( link: LinkIncludingShortenedCollectionAndTags ) => { @@ -117,141 +123,49 @@ export default function LinkCardCompact({ onChange={() => handleCheckboxClick(link)} /> )} */} - {!editMode ? ( - <> - -
- -
+
+ !editMode && window.open(generateLinkHref(link, account), "_blank") + } + > +
+ +
-
-

- {unescapeString(link.name || link.description) || link.url} -

+
+

+ {unescapeString(link.name || link.description) || link.url} +

-
-
- {collection && ( - - )} - {link.url ? ( -
- -

{shortendURL}

-
- ) : ( -
- {link.type} -
- )} - +
+
+ {collection ? ( + + ) : undefined} + {link.url ? ( +
+ +

{shortendURL}

-
-
- - setShowInfo(!showInfo)} - // linkInfo={showInfo} - /> - {showInfo && ( -
-
-

- Description -

- -
-

- {link.description ? ( - unescapeString(link.description) - ) : ( - - No description provided. - - )} -

- {link.tags[0] && ( - <> -

- Tags -

- -
- -
-
- {link.tags.map((e, i) => ( - { - e.stopPropagation(); - }} - className="btn btn-xs btn-ghost truncate max-w-[19rem]" - > - #{e.name} - - ))} -
-
- - )} -
-
- )} - - ) : ( - <> -
-
- -
- -
-

- {unescapeString(link.name || link.description) || link.url} -

- -
-
- {collection ? ( - - ) : undefined} - {link.url ? ( -
- -

- {shortendURL} -

-
- ) : ( -
- {link.type} -
- )} - + ) : ( +
+ {link.type}
-
+ )} +
- setShowInfo(!showInfo)} - // linkInfo={showInfo} - /> - - )} +
+
+ setShowInfo(!showInfo)} + // linkInfo={showInfo} + />
diff --git a/pages/collections/[id].tsx b/pages/collections/[id].tsx index a4cac87..92456a7 100644 --- a/pages/collections/[id].tsx +++ b/pages/collections/[id].tsx @@ -97,10 +97,9 @@ export default function Index() { const [bulkDeleteLinksModal, setBulkDeleteLinksModal] = useState(false); const [bulkEditLinksModal, setBulkEditLinksModal] = useState(false); const [editMode, setEditMode] = useState(false); + useEffect(() => { - return () => { - setEditMode(false); - }; + if (editMode) return setEditMode(false); }, [router]); const [viewMode, setViewMode] = useState( diff --git a/pages/links/index.tsx b/pages/links/index.tsx index e8f1d98..b6b67c3 100644 --- a/pages/links/index.tsx +++ b/pages/links/index.tsx @@ -30,10 +30,9 @@ export default function Links() { const [bulkDeleteLinksModal, setBulkDeleteLinksModal] = useState(false); const [bulkEditLinksModal, setBulkEditLinksModal] = useState(false); const [editMode, setEditMode] = useState(false); + useEffect(() => { - return () => { - setEditMode(false); - }; + if (editMode) return setEditMode(false); }, [router]); const collectivePermissions = useCollectivePermissions( diff --git a/pages/links/pinned.tsx b/pages/links/pinned.tsx index f07f81a..ecdec4e 100644 --- a/pages/links/pinned.tsx +++ b/pages/links/pinned.tsx @@ -30,10 +30,9 @@ export default function PinnedLinks() { const [bulkDeleteLinksModal, setBulkDeleteLinksModal] = useState(false); const [bulkEditLinksModal, setBulkEditLinksModal] = useState(false); const [editMode, setEditMode] = useState(false); + useEffect(() => { - return () => { - setEditMode(false); - }; + if (editMode) return setEditMode(false); }, [router]); const collectivePermissions = useCollectivePermissions( diff --git a/pages/tags/[id].tsx b/pages/tags/[id].tsx index 1d527f4..34d172f 100644 --- a/pages/tags/[id].tsx +++ b/pages/tags/[id].tsx @@ -33,10 +33,9 @@ export default function Index() { const [bulkDeleteLinksModal, setBulkDeleteLinksModal] = useState(false); const [bulkEditLinksModal, setBulkEditLinksModal] = useState(false); const [editMode, setEditMode] = useState(false); + useEffect(() => { - return () => { - setEditMode(false); - }; + if (editMode) return setEditMode(false); }, [router]); const collectivePermissions = useCollectivePermissions(