Skip to content

Commit

Permalink
fix: only create zip if more than one file is in the share
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith404 committed Dec 11, 2022
1 parent 7c0d62a commit 3d1d4d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions backend/src/share/share.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ export class ShareService {
);

// Asynchronously create a zip of all files
this.createZip(id).then(() =>
this.prisma.share.update({ where: { id }, data: { isZipReady: true } })
);
if (share.files.length > 1)
this.createZip(id).then(() =>
this.prisma.share.update({ where: { id }, data: { isZipReady: true } })
);

// Send email for each recepient
for (const recepient of share.recipients) {
Expand Down
18 changes: 8 additions & 10 deletions frontend/src/pages/share/[shareId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function getServerSideProps(context: GetServerSidePropsContext) {

const Share = ({ shareId }: { shareId: string }) => {
const modals = useModals();
const [fileList, setFileList] = useState<any[]>([]);
const [files, setFiles] = useState<any[]>([]);

const getShareToken = async (password?: string) => {
await shareService
Expand All @@ -41,7 +41,7 @@ const Share = ({ shareId }: { shareId: string }) => {
shareService
.get(shareId)
.then((share) => {
setFileList(share.files);
setFiles(share.files);
})
.catch((e) => {
const { error } = e.response.data;
Expand Down Expand Up @@ -77,14 +77,12 @@ const Share = ({ shareId }: { shareId: string }) => {
title={`Share ${shareId}`}
description="Look what I've shared with you."
/>
<Group position="right" mb="lg">
<DownloadAllButton shareId={shareId} />
</Group>
<FileList
files={fileList}
shareId={shareId}
isLoading={fileList.length == 0}
/>
{files.length > 1 && (
<Group position="right" mb="lg">
<DownloadAllButton shareId={shareId} />
</Group>
)}
<FileList files={files} shareId={shareId} isLoading={files.length == 0} />
</>
);
};
Expand Down

0 comments on commit 3d1d4d0

Please sign in to comment.