Skip to content

Commit 9cdfc7e

Browse files
authored
improvement: only show uploading card when uploading a video (#996)
* Update Caps.tsx * Update FolderVideosSection.tsx
1 parent 3b0eb5b commit 9cdfc7e

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

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

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export const Caps = ({
7878
setIsUploading,
7979
setUploadingCapId,
8080
setUploadProgress,
81+
uploadingCapId,
8182
setUploadingThumbnailUrl,
8283
} = useUploadingContext();
8384

@@ -321,27 +322,31 @@ export const Caps = ({
321322
{isUploading && (
322323
<UploadPlaceholderCard key={"upload-placeholder"} />
323324
)}
324-
{data.map((cap) => (
325-
<CapCard
326-
key={cap.id}
327-
cap={cap}
328-
analytics={analytics[cap.id] || 0}
329-
onDelete={() => {
330-
if (selectedCaps.length > 0) {
331-
deleteCaps(selectedCaps);
332-
} else {
333-
deleteCap(cap.id);
334-
}
335-
}}
336-
userId={user?.id}
337-
customDomain={customDomain}
338-
isLoadingAnalytics={isLoadingAnalytics}
339-
domainVerified={domainVerified}
340-
isSelected={selectedCaps.includes(cap.id)}
341-
anyCapSelected={anyCapSelected}
342-
onSelectToggle={() => handleCapSelection(cap.id)}
343-
/>
344-
))}
325+
{data
326+
.filter((cap) => !isUploading || cap.id !== uploadingCapId)
327+
.map((cap) => {
328+
return (
329+
<CapCard
330+
key={cap.id}
331+
cap={cap}
332+
analytics={analytics[cap.id] || 0}
333+
onDelete={() => {
334+
if (selectedCaps.length > 0) {
335+
deleteCaps(selectedCaps);
336+
} else {
337+
deleteCap(cap.id);
338+
}
339+
}}
340+
userId={user?.id}
341+
customDomain={customDomain}
342+
isLoadingAnalytics={isLoadingAnalytics}
343+
domainVerified={domainVerified}
344+
isSelected={selectedCaps.includes(cap.id)}
345+
anyCapSelected={anyCapSelected}
346+
onSelectToggle={() => handleCapSelection(cap.id)}
347+
/>
348+
);
349+
})}
345350
</div>
346351
</>
347352
)}

apps/web/app/(org)/dashboard/folder/[id]/components/FolderVideosSection.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function FolderVideosSection({
2727
cardType = "default",
2828
}: FolderVideosSectionProps) {
2929
const router = useRouter();
30-
const { isUploading } = useUploadingContext();
30+
const { isUploading, uploadingCapId } = useUploadingContext();
3131
const { activeOrganization, user } = useDashboardContext();
3232

3333
const [selectedCaps, setSelectedCaps] = useState<Video.VideoId[]>([]);
@@ -164,20 +164,22 @@ export default function FolderVideosSection({
164164
{isUploading && (
165165
<UploadPlaceholderCard key={"upload-placeholder"} />
166166
)}
167-
{initialVideos.map((video) => (
168-
<CapCard
169-
key={video.id}
170-
cap={video}
171-
analytics={analytics[video.id] || 0}
172-
userId={user?.id}
173-
isLoadingAnalytics={isLoadingAnalytics}
174-
isSelected={selectedCaps.includes(video.id)}
175-
anyCapSelected={selectedCaps.length > 0}
176-
isDeleting={deleteCaps.isPending}
177-
onSelectToggle={() => handleCapSelection(video.id)}
178-
onDelete={() => deleteCaps.mutateAsync(selectedCaps)}
179-
/>
180-
))}
167+
{initialVideos
168+
.filter((cap) => !isUploading || cap.id !== uploadingCapId)
169+
.map((video) => (
170+
<CapCard
171+
key={video.id}
172+
cap={video}
173+
analytics={analytics[video.id] || 0}
174+
userId={user?.id}
175+
isLoadingAnalytics={isLoadingAnalytics}
176+
isSelected={selectedCaps.includes(video.id)}
177+
anyCapSelected={selectedCaps.length > 0}
178+
isDeleting={deleteCaps.isPending}
179+
onSelectToggle={() => handleCapSelection(video.id)}
180+
onDelete={() => deleteCaps.mutateAsync(selectedCaps)}
181+
/>
182+
))}
181183
</>
182184
)}
183185
</div>

0 commit comments

Comments
 (0)