1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-10-02 09:30:10 +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,6 +105,7 @@ export class ShareService {
); );
// Asynchronously create a zip of all files // Asynchronously create a zip of all files
if (share.files.length > 1)
this.createZip(id).then(() => this.createZip(id).then(() =>
this.prisma.share.update({ where: { id }, data: { isZipReady: true } }) this.prisma.share.update({ where: { id }, data: { isZipReady: true } })
); );

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."
/> />
{files.length > 1 && (
<Group position="right" mb="lg"> <Group position="right" mb="lg">
<DownloadAllButton shareId={shareId} /> <DownloadAllButton shareId={shareId} />
</Group> </Group>
<FileList )}
files={fileList} <FileList files={files} shareId={shareId} isLoading={files.length == 0} />
shareId={shareId}
isLoading={fileList.length == 0}
/>
</> </>
); );
}; };