mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-29 01:28:59 -05:00
fix: only create zip if more than one file is in the share
This commit is contained in:
parent
7c0d62a429
commit
3d1d4d0fc7
2 changed files with 12 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue