Skip to content

Commit

Permalink
fix: Saving thumbnails
Browse files Browse the repository at this point in the history
  • Loading branch information
cyaiox committed Mar 16, 2023
1 parent 06b5b78 commit f569dec
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -918,20 +918,22 @@ export default class CreateSingleItemModal extends React.PureComponent<Props, St
}

handleOnScreenshotTaken = async (screenshot: string) => {
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 })
)
}
}

Expand Down

0 comments on commit f569dec

Please sign in to comment.