⚡️⚡️⚡️ 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
minor improvements
daniel31x13daed2d82f4ff
diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsxindex 4e04f473..d809dfc8 100644--- a/components/LinkViews/LinkComponents/LinkActions.tsx+++ b/components/LinkViews/LinkComponents/LinkActions.tsx@@ -67,8 +67,9 @@ export default function LinkActions({return (<><div- className={`dropdown dropdown-left dropdown-end absolute ${position || "top-3 right-3"- } z-20`}+ className={`dropdown dropdown-left dropdown-end absolute ${+ position || "top-3 right-3"+ } z-20`}><divtabIndex={0}@@ -79,22 +80,20 @@ export default function LinkActions({<i title="More" className="bi-three-dots text-xl" /></div><ul className="dropdown-content z-[20] menu shadow bg-base-200 border border-neutral-content rounded-box w-44 mr-1 translate-y-10">- {permissions ? (- <li>- <div- role="button"- tabIndex={0}- onClick={() => {- (document?.activeElement as HTMLElement)?.blur();- pinLink();- }}- >- {link?.pinnedBy && link.pinnedBy[0]- ? "Unpin"- : "Pin to Dashboard"}- </div>- </li>- ) : undefined}+ <li>+ <div+ role="button"+ tabIndex={0}+ onClick={() => {+ (document?.activeElement as HTMLElement)?.blur();+ pinLink();+ }}+ >+ {link?.pinnedBy && link.pinnedBy[0]+ ? "Unpin"+ : "Pin to Dashboard"}+ </div>+ </li>{linkInfo !== undefined && toggleShowInfo ? (<li><divdiff --git a/lib/api/controllers/links/linkId/updateLinkById.ts b/lib/api/controllers/links/linkId/updateLinkById.tsindex c7b1f84b..ce6b9207 100644--- a/lib/api/controllers/links/linkId/updateLinkById.ts+++ b/lib/api/controllers/links/linkId/updateLinkById.ts@@ -21,10 +21,6 @@ export default async function updateLinkById((e: UsersAndCollections) => e.userId === userId && e.canUpdate);- const canCreatePermission = collectionIsAccessible?.members.some(- (e: UsersAndCollections) => e.userId === userId && e.canCreate- );-const isCollectionOwner =collectionIsAccessible?.ownerId === data.collection.ownerId &&data.collection.ownerId === userId;@@ -32,31 +28,29 @@ export default async function updateLinkById(const unauthorizedSwitchCollection =!isCollectionOwner && collectionIsAccessible?.id !== data.collection.id;- // Makes sure collection members (non-owners) cannot move a link to/from a collection.- if (unauthorizedSwitchCollection)- return {- response: "You can't move a link to/from a collection you don't own.",- status: 401,- };+ const canPinPermission = collectionIsAccessible?.members.some(+ (e: UsersAndCollections) => e.userId === userId+ );// If the user is able to create a link, they can pin it to their dashboard only.- if (canCreatePermission) {+ if (canPinPermission) {const updatedLink = await prisma.link.update({where: {id: linkId,},data: {- pinnedBy: data?.pinnedBy && data.pinnedBy[0]- ? { connect: { id: userId } }- : { disconnect: { id: userId } },+ pinnedBy:+ data?.pinnedBy && data.pinnedBy[0]+ ? { connect: { id: userId } }+ : { disconnect: { id: userId } },},include: {collection: true,pinnedBy: isCollectionOwner? {- where: { id: userId },- select: { id: true },- }+ where: { id: userId },+ select: { id: true },+ }: undefined,},});@@ -64,6 +58,12 @@ export default async function updateLinkById(return { response: updatedLink, status: 200 };}+ // Makes sure collection members (non-owners) cannot move a link to/from a collection.+ if (unauthorizedSwitchCollection)+ return {+ response: "You can't move a link to/from a collection you don't own.",+ status: 401,+ };else if (collectionIsAccessible?.ownerId !== userId && !memberHasAccess)return {response: "Collection is not accessible.",@@ -111,9 +111,9 @@ export default async function updateLinkById(collection: true,pinnedBy: isCollectionOwner? {- where: { id: userId },- select: { id: true },- }+ where: { id: userId },+ select: { id: true },+ }: undefined,},});