From f569dec62a5b02db5f5ffff95f1fa83203e420a6 Mon Sep 17 00:00:00 2001 From: Gabriel Diaz Date: Thu, 16 Mar 2023 15:56:09 -0300 Subject: [PATCH] fix: Saving thumbnails --- .../CreateSingleItemModal.tsx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/components/Modals/CreateSingleItemModal/CreateSingleItemModal.tsx b/src/components/Modals/CreateSingleItemModal/CreateSingleItemModal.tsx index 70ef8a9333..6612b7496e 100644 --- a/src/components/Modals/CreateSingleItemModal/CreateSingleItemModal.tsx +++ b/src/components/Modals/CreateSingleItemModal/CreateSingleItemModal.tsx @@ -918,20 +918,22 @@ export default class CreateSingleItemModal extends React.PureComponent { - const { fromView, itemSortedContents, item } = this.state + const { fromView, itemSortedContents, item, contents } = this.state const view = fromView === CreateItemView.DETAILS ? CreateItemView.DETAILS : CreateItemView.SET_PRICE + const blob = dataURLToBlob(screenshot) as Blob if (item && itemSortedContents) { - const blob = dataURLToBlob(screenshot) + itemSortedContents[THUMBNAIL_PATH] = blob + item.contents = await computeHashes(itemSortedContents) - if (blob) { - itemSortedContents[THUMBNAIL_PATH] = blob - item.contents = await computeHashes(itemSortedContents) - - this.setState({ itemSortedContents, item, hasScreenshotTaken: true }, () => this.handleSubmit()) - } + this.setState( + { thumbnail: screenshot, itemSortedContents, item, contents: { ...contents, [THUMBNAIL_PATH]: blob }, hasScreenshotTaken: true }, + () => this.handleSubmit() + ) } else { - this.setState({ thumbnail: screenshot, hasScreenshotTaken: true }, () => this.setState({ view })) + this.setState({ thumbnail: screenshot, contents: { ...contents, [THUMBNAIL_PATH]: blob }, hasScreenshotTaken: true }, () => + this.setState({ view }) + ) } }