Skip to content

Commit 4b9eb28

Browse files
authored
web: fix delete comment, spaces custom domain link (#1159)
* fix copy link in spaces * fix delete comment * Update Comment.tsx * ts * ts
1 parent 2169b42 commit 4b9eb28

File tree

6 files changed

+43
-66
lines changed

6 files changed

+43
-66
lines changed

apps/web/actions/videos/delete-comment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function deleteComment({
1313
videoId,
1414
}: {
1515
commentId: Comment.CommentId;
16-
parentId?: Comment.CommentId;
16+
parentId: Comment.CommentId | null;
1717
videoId: Video.VideoId;
1818
}) {
1919
const user = await getCurrentUser();

apps/web/app/(org)/dashboard/caps/Caps.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,11 @@ export type VideoData = {
5252
export const Caps = ({
5353
data,
5454
count,
55-
customDomain,
56-
domainVerified,
5755
dubApiKeyEnabled,
5856
folders,
5957
}: {
6058
data: VideoData;
6159
count: number;
62-
customDomain: string | null;
63-
domainVerified: boolean;
6460
folders: FolderDataType[];
6561
dubApiKeyEnabled: boolean;
6662
}) => {
@@ -322,9 +318,7 @@ export const Caps = ({
322318
}
323319
}}
324320
userId={user?.id}
325-
customDomain={customDomain}
326321
isLoadingAnalytics={isLoadingAnalytics}
327-
domainVerified={domainVerified}
328322
isSelected={selectedCaps.includes(video.id)}
329323
anyCapSelected={anyCapSelected}
330324
onSelectToggle={() => handleCapSelection(video.id)}

apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ export interface CapCardProps extends PropsWithChildren {
9292
sharedCapCard?: boolean;
9393
isSelected?: boolean;
9494
onSelectToggle?: () => void;
95-
customDomain?: string | null;
96-
domainVerified?: boolean;
9795
hideSharedStatus?: boolean;
9896
anyCapSelected?: boolean;
9997
isDeleting?: boolean;
@@ -110,13 +108,15 @@ export const CapCard = ({
110108
isLoadingAnalytics,
111109
sharedCapCard = false,
112110
hideSharedStatus = false,
113-
customDomain,
114-
domainVerified,
115111
isSelected = false,
116112
onSelectToggle,
117113
anyCapSelected = false,
118114
isDeleting = false,
119115
}: CapCardProps) => {
116+
const { activeOrganization } = useDashboardContext();
117+
const customDomain = activeOrganization?.organization.customDomain;
118+
const domainVerified = activeOrganization?.organization.domainVerified;
119+
120120
const [isSharingDialogOpen, setIsSharingDialogOpen] = useState(false);
121121
const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState(false);
122122
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
@@ -294,6 +294,18 @@ export const CapCard = ({
294294
}
295295
};
296296

297+
const copyLinkHandler = () => {
298+
handleCopy(
299+
NODE_ENV === "development"
300+
? `${webUrl}/s/${cap.id}`
301+
: buildEnv.NEXT_PUBLIC_IS_CAP && customDomain && domainVerified
302+
? `https://${customDomain}/s/${cap.id}`
303+
: buildEnv.NEXT_PUBLIC_IS_CAP && !customDomain && !domainVerified
304+
? `https://cap.link/${cap.id}`
305+
: `${webUrl}/s/${cap.id}`,
306+
);
307+
};
308+
297309
return (
298310
<>
299311
<SharingDialog
@@ -376,45 +388,31 @@ export const CapCard = ({
376388
tooltipContent="Copy link"
377389
onClick={(e) => {
378390
e.stopPropagation();
379-
handleCopy(
380-
NODE_ENV === "development"
381-
? `${webUrl}/s/${cap.id}`
382-
: buildEnv.NEXT_PUBLIC_IS_CAP &&
383-
customDomain &&
384-
domainVerified
385-
? `https://${customDomain}/s/${cap.id}`
386-
: buildEnv.NEXT_PUBLIC_IS_CAP &&
387-
!customDomain &&
388-
!domainVerified
389-
? `https://cap.link/${cap.id}`
390-
: `${webUrl}/s/${cap.id}`,
391-
);
391+
copyLinkHandler();
392392
}}
393393
className="delay-0"
394394
icon={
395-
<>
396-
{!copyPressed ? (
397-
<FontAwesomeIcon
398-
className="text-gray-12 size-4"
399-
icon={faLink}
400-
/>
401-
) : (
402-
<svg
403-
xmlns="http://www.w3.org/2000/svg"
404-
width="24"
405-
height="24"
406-
viewBox="0 0 24 24"
407-
fill="none"
408-
stroke="currentColor"
409-
strokeWidth="2"
410-
strokeLinecap="round"
411-
strokeLinejoin="round"
412-
className="text-gray-12 size-5 svgpathanimation"
413-
>
414-
<path d="M20 6 9 17l-5-5" />
415-
</svg>
416-
)}
417-
</>
395+
!copyPressed ? (
396+
<FontAwesomeIcon
397+
className="text-gray-12 size-4"
398+
icon={faLink}
399+
/>
400+
) : (
401+
<svg
402+
xmlns="http://www.w3.org/2000/svg"
403+
width="24"
404+
height="24"
405+
viewBox="0 0 24 24"
406+
fill="none"
407+
stroke="currentColor"
408+
strokeWidth="2"
409+
strokeLinecap="round"
410+
strokeLinejoin="round"
411+
className="text-gray-12 size-5 svgpathanimation"
412+
>
413+
<path d="M20 6 9 17l-5-5" />
414+
</svg>
415+
)
418416
}
419417
/>
420418
)}
@@ -448,17 +446,7 @@ export const CapCard = ({
448446
<DropdownMenuItem
449447
onClick={(e) => {
450448
e.stopPropagation();
451-
handleCopy(
452-
buildEnv.NEXT_PUBLIC_IS_CAP &&
453-
NODE_ENV === "production" &&
454-
customDomain &&
455-
domainVerified
456-
? `https://${customDomain}/s/${cap.id}`
457-
: buildEnv.NEXT_PUBLIC_IS_CAP &&
458-
NODE_ENV === "production"
459-
? `https://cap.link/${cap.id}`
460-
: `${location.origin}/s/${cap.id}`,
461-
);
449+
copyLinkHandler();
462450
toast.success("Link copied to clipboard");
463451
}}
464452
className="flex gap-2 items-center rounded-lg"

apps/web/app/(org)/dashboard/caps/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ export default async function CapsPage(props: PageProps<"/dashboard/caps">) {
267267
<Caps
268268
data={processedVideoData}
269269
folders={foldersData}
270-
customDomain={customDomain}
271-
domainVerified={domainVerified}
272270
count={totalCount}
273271
dubApiKeyEnabled={!!serverEnv().DUB_API_KEY}
274272
/>

apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const CommentComponent: React.FC<{
2222
onCancelReply: () => void;
2323
onDelete: (
2424
commentId: Comment.CommentId,
25-
parentId?: Comment.CommentId,
25+
parentId: Comment.CommentId | null,
2626
) => void;
2727
user: typeof userSelectProps | null;
2828
level?: number;
@@ -55,10 +55,7 @@ const CommentComponent: React.FC<{
5555
: [];
5656

5757
const handleDelete = () => {
58-
if (
59-
comment.parentCommentId &&
60-
window.confirm("Are you sure you want to delete this comment?")
61-
) {
58+
if (window.confirm("Are you sure you want to delete this comment?")) {
6259
onDelete(comment.id, comment.parentCommentId);
6360
}
6461
};

apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export const Comments = Object.assign(
174174

175175
const handleDeleteComment = async (
176176
commentId: Comment.CommentId,
177-
parentId?: Comment.CommentId,
177+
parentId: Comment.CommentId | null,
178178
) => {
179179
try {
180180
await deleteComment({

0 commit comments

Comments
 (0)