1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-10-02 01:20:11 +02:00

fix: only create zip if more than one file is in the share

This commit is contained in:
Elias Schneider 2022-12-11 12:19:42 +01:00
parent 7c0d62a429
commit 3d1d4d0fc7
2 changed files with 12 additions and 13 deletions

View File

@ -105,9 +105,10 @@ export class ShareService {
); );
// Asynchronously create a zip of all files // Asynchronously create a zip of all files
this.createZip(id).then(() => if (share.files.length > 1)
this.prisma.share.update({ where: { id }, data: { isZipReady: true } }) this.createZip(id).then(() =>
); this.prisma.share.update({ where: { id }, data: { isZipReady: true } })
);
// Send email for each recepient // Send email for each recepient
for (const recepient of share.recipients) { for (const recepient of share.recipients) {

View File

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