Skip to content

Commit

Permalink
feat: wrapped uploads with js-ipfs v0.29.0
Browse files Browse the repository at this point in the history
Closes #482
  • Loading branch information
lidel committed May 29, 2018
1 parent e0f609f commit c38ac36
Show file tree
Hide file tree
Showing 3 changed files with 471 additions and 474 deletions.
14 changes: 7 additions & 7 deletions add-on/src/popup/quick-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ function quickUploadStore (state, emitter) {
}
progressHandler(0, totalSize, state, emitter)
emitter.emit('render')
// TODO: update flag below after wrapping support is released with new js-ipfs
// TODO: also enable multiple file selection in <input type=file> (blocked for js-ipfs for now)
const wrapFlag = (state.wrapWithDirectory || files.length > 1) && state.ipfsNodeType !== 'embedded'
const wrapFlag = (state.wrapWithDirectory || files.length > 1)
const uploadOptions = {
progress: (len) => progressHandler(len, totalSize, state, emitter),
wrapWithDirectory: wrapFlag,
Expand All @@ -123,6 +121,7 @@ function quickUploadOptions (state, emit) {
const onExpandOptions = (e) => { state.expandOptions = true; emit('render') }
const onWrapWithDirectoryChange = (e) => { state.wrapWithDirectory = e.target.checked }
const onPinUploadChange = (e) => { state.pinUpload = e.target.checked }
const isPinningSupported = state.ipfsNodeType === 'external'
if (state.expandOptions) {
return html`
<div id='quickUploadOptions' class='sans-serif mt3 f6 lh-copy light-gray no-user-select'>
Expand All @@ -131,11 +130,13 @@ function quickUploadOptions (state, emit) {
<span class='mark db flex items-center relative mr2 br2'></span>
${browser.i18n.getMessage('quickUpload_options_wrapWithDirectory')}
</label>
${isPinningSupported ? (html`
<label for='pinUpload' class='flex items-center db relative mt1 pointer'>
<input id='pinUpload' type='checkbox' onchange=${onPinUploadChange} checked=${state.pinUpload} />
<span class='mark db flex items-center relative mr2 br2'></span>
${browser.i18n.getMessage('quickUpload_options_pinUpload')}
</label>
</label>`)
: null}
</div>
`
}
Expand Down Expand Up @@ -169,7 +170,7 @@ function quickUploadPage (state, emit) {
</div>
</header>
<label for="quickUploadInput" class='db relative mt5 hover-inner-shadow' style="border:solid 2px #6ACAD1">
<input class="db pointer w-100 h-100 top-0 o-0" type="file" id="quickUploadInput" ${state.ipfsNodeType === 'external' ? 'multiple' : null} onchange=${onFileInputChange} />
<input class="db pointer w-100 h-100 top-0 o-0" type="file" id="quickUploadInput" multiple onchange=${onFileInputChange} />
<div class='dt dim' style='padding-left: 100px; height: 300px'>
<div class='dtc v-mid'>
<span class="f3 link dim br1 ph4 pv3 dib white" style="background: #6ACAD1">
Expand All @@ -185,8 +186,7 @@ function quickUploadPage (state, emit) {
</div>
</div>
</label>
<!-- TODO: enable wrapping in embedded node after js-ipfs release -->
${state.ipfsNodeType === 'external' ? quickUploadOptions(state, emit) : null}
${quickUploadOptions(state, emit)}
</div>
</div>
`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"file-type": "8.0.0",
"filereader-pull-stream": "1.0.0",
"filesize": "3.6.1",
"ipfs": "0.28.2",
"ipfs": "0.29.0",
"ipfs-api": "22.0.0",
"ipfs-css": "0.5.0",
"ipfs-postmsg-proxy": "2.16.1",
Expand Down
Loading

0 comments on commit c38ac36

Please sign in to comment.