Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/actions/videos/delete-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function deleteComment({
videoId,
}: {
commentId: Comment.CommentId;
parentId?: Comment.CommentId;
parentId: Comment.CommentId | null;
videoId: Video.VideoId;
}) {
const user = await getCurrentUser();
Expand Down
6 changes: 0 additions & 6 deletions apps/web/app/(org)/dashboard/caps/Caps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ export type VideoData = {
export const Caps = ({
data,
count,
customDomain,
domainVerified,
dubApiKeyEnabled,
folders,
}: {
data: VideoData;
count: number;
customDomain: string | null;
domainVerified: boolean;
folders: FolderDataType[];
dubApiKeyEnabled: boolean;
}) => {
Expand Down Expand Up @@ -322,9 +318,7 @@ export const Caps = ({
}
}}
userId={user?.id}
customDomain={customDomain}
isLoadingAnalytics={isLoadingAnalytics}
domainVerified={domainVerified}
isSelected={selectedCaps.includes(video.id)}
anyCapSelected={anyCapSelected}
onSelectToggle={() => handleCapSelection(video.id)}
Expand Down
90 changes: 39 additions & 51 deletions apps/web/app/(org)/dashboard/caps/components/CapCard/CapCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export interface CapCardProps extends PropsWithChildren {
sharedCapCard?: boolean;
isSelected?: boolean;
onSelectToggle?: () => void;
customDomain?: string | null;
domainVerified?: boolean;
hideSharedStatus?: boolean;
anyCapSelected?: boolean;
isDeleting?: boolean;
Expand All @@ -110,13 +108,15 @@ export const CapCard = ({
isLoadingAnalytics,
sharedCapCard = false,
hideSharedStatus = false,
customDomain,
domainVerified,
isSelected = false,
onSelectToggle,
anyCapSelected = false,
isDeleting = false,
}: CapCardProps) => {
const { activeOrganization } = useDashboardContext();
const customDomain = activeOrganization?.organization.customDomain;
const domainVerified = activeOrganization?.organization.domainVerified;

const [isSharingDialogOpen, setIsSharingDialogOpen] = useState(false);
const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState(false);
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
Expand Down Expand Up @@ -294,6 +294,18 @@ export const CapCard = ({
}
};

const copyLinkHandler = () => {
handleCopy(
NODE_ENV === "development"
? `${webUrl}/s/${cap.id}`
: buildEnv.NEXT_PUBLIC_IS_CAP && customDomain && domainVerified
? `https://${customDomain}/s/${cap.id}`
: buildEnv.NEXT_PUBLIC_IS_CAP && !customDomain && !domainVerified
? `https://cap.link/${cap.id}`
: `${webUrl}/s/${cap.id}`,
);
};

return (
<>
<SharingDialog
Expand Down Expand Up @@ -376,45 +388,31 @@ export const CapCard = ({
tooltipContent="Copy link"
onClick={(e) => {
e.stopPropagation();
handleCopy(
NODE_ENV === "development"
? `${webUrl}/s/${cap.id}`
: buildEnv.NEXT_PUBLIC_IS_CAP &&
customDomain &&
domainVerified
? `https://${customDomain}/s/${cap.id}`
: buildEnv.NEXT_PUBLIC_IS_CAP &&
!customDomain &&
!domainVerified
? `https://cap.link/${cap.id}`
: `${webUrl}/s/${cap.id}`,
);
copyLinkHandler();
}}
className="delay-0"
icon={
<>
{!copyPressed ? (
<FontAwesomeIcon
className="text-gray-12 size-4"
icon={faLink}
/>
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="text-gray-12 size-5 svgpathanimation"
>
<path d="M20 6 9 17l-5-5" />
</svg>
)}
</>
!copyPressed ? (
<FontAwesomeIcon
className="text-gray-12 size-4"
icon={faLink}
/>
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="text-gray-12 size-5 svgpathanimation"
>
<path d="M20 6 9 17l-5-5" />
</svg>
)
}
/>
)}
Expand Down Expand Up @@ -448,17 +446,7 @@ export const CapCard = ({
<DropdownMenuItem
onClick={(e) => {
e.stopPropagation();
handleCopy(
buildEnv.NEXT_PUBLIC_IS_CAP &&
NODE_ENV === "production" &&
customDomain &&
domainVerified
? `https://${customDomain}/s/${cap.id}`
: buildEnv.NEXT_PUBLIC_IS_CAP &&
NODE_ENV === "production"
? `https://cap.link/${cap.id}`
: `${location.origin}/s/${cap.id}`,
);
copyLinkHandler();
toast.success("Link copied to clipboard");
}}
className="flex gap-2 items-center rounded-lg"
Expand Down
2 changes: 0 additions & 2 deletions apps/web/app/(org)/dashboard/caps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ export default async function CapsPage(props: PageProps<"/dashboard/caps">) {
<Caps
data={processedVideoData}
folders={foldersData}
customDomain={customDomain}
domainVerified={domainVerified}
count={totalCount}
dubApiKeyEnabled={!!serverEnv().DUB_API_KEY}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const CommentComponent: React.FC<{
onCancelReply: () => void;
onDelete: (
commentId: Comment.CommentId,
parentId?: Comment.CommentId,
parentId: Comment.CommentId | null,
) => void;
user: typeof userSelectProps | null;
level?: number;
Expand Down Expand Up @@ -55,10 +55,7 @@ const CommentComponent: React.FC<{
: [];

const handleDelete = () => {
if (
comment.parentCommentId &&
window.confirm("Are you sure you want to delete this comment?")
) {
if (window.confirm("Are you sure you want to delete this comment?")) {
onDelete(comment.id, comment.parentCommentId);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const Comments = Object.assign(

const handleDeleteComment = async (
commentId: Comment.CommentId,
parentId?: Comment.CommentId,
parentId: Comment.CommentId | null,
) => {
try {
await deleteComment({
Expand Down