FileDecrypter: do not create object url in render

This commit is contained in:
Peter Cai 2020-02-19 16:21:39 +08:00
parent 1140040bcc
commit 7966135ac7
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
1 changed files with 7 additions and 2 deletions

View File

@ -36,6 +36,10 @@ class FileDecrypter extends React.Component
mime: mime
length: parseInt resp.headers.get 'content-length'
componentWillUnmount: ->
if @state.downloaded
URL.revokeObjectURL @state.downloaded
downloadFile: =>
@setState
downloading: true
@ -65,7 +69,8 @@ class FileDecrypter extends React.Component
type: @state.mime
@setState
decrypting: false
downloaded: blob
blob: blob
downloaded: URL.createObjectURL blob
render: ->
<div className="content-pastebin">{
@ -95,7 +100,7 @@ class FileDecrypter extends React.Component
# on a hidden link, because on some browsers it doesn't work
<a
className="button-blue"
href={URL.createObjectURL @state.downloaded}
href={@state.downloaded}
download={@state.name}
>
Save File