Skip to content

Commit

Permalink
[import] Fix spinner issue on no references/assets (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars authored and bjoerge committed Oct 16, 2018
1 parent c9beafa commit 8a041b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/@sanity/import/src/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function strengthenReferences(strongRefs, options) {
batches.push(strongRefs.slice(i, i + STRENGTHEN_BATCH_SIZE))
}

if (batches.length === 0) {
return Promise.resolve([0])
}

const progress = progressStepper(options.onProgress, {
step: 'Strengthening references',
total: batches.length
Expand Down
8 changes: 8 additions & 0 deletions packages/@sanity/import/src/uploadAssets.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ async function uploadAssets(assets, options) {
}
})

if (assetRefMap.size === 0) {
return Promise.resolve(0)
}

// Create a function we can call for every completed upload to report progress
const progress = progressStepper(options.onProgress, {
step: 'Importing assets (files/images)',
Expand Down Expand Up @@ -138,6 +142,10 @@ function setAssetReferences(assetRefMap, assetIds, options) {
batches.push(patchTasks.slice(i, i + ASSET_PATCH_BATCH_SIZE))
}

if (batches.length === 0) {
return Promise.resolve([0])
}

// Since separate progress step for batches of reference sets
const progress = progressStepper(options.onProgress, {
step: 'Setting asset references to documents',
Expand Down

0 comments on commit 8a041b5

Please sign in to comment.