From ba277a5238fce8964573c199f99c7aa559835294 Mon Sep 17 00:00:00 2001 From: Paul Kaplan <pkaplan@media.mit.edu> Date: Fri, 8 Feb 2019 11:42:09 -0500 Subject: [PATCH] Fix namer conventions to be less bizarre --- src/containers/target-pane.jsx | 4 ++-- src/lib/file-uploader.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/containers/target-pane.jsx b/src/containers/target-pane.jsx index 2fdea2651..e4d0f3664 100644 --- a/src/containers/target-pane.jsx +++ b/src/containers/target-pane.jsx @@ -136,9 +136,9 @@ class TargetPane extends React.Component { handleSpriteUpload (e) { const storage = this.props.vm.runtime.storage; handleFileUpload(e.target, (buffer, fileType, fileName) => { - const pluralizeCostume = i => this.props.intl.formatMessage( + const costumeSuffixer = i => this.props.intl.formatMessage( sharedMessages.costume, {index: i}); - spriteUpload(buffer, fileType, fileName, storage, this.handleNewSprite, pluralizeCostume); + spriteUpload(buffer, fileType, fileName, storage, this.handleNewSprite, costumeSuffixer); }); } setFileInput (input) { diff --git a/src/lib/file-uploader.js b/src/lib/file-uploader.js index a017bd4e6..da938a4aa 100644 --- a/src/lib/file-uploader.js +++ b/src/lib/file-uploader.js @@ -90,18 +90,18 @@ const createVMAsset = function (storage, fileName, assetType, dataFormat, data) * @param {ArrayBuffer | string} fileData The costume data to load (this can be a base64 string * iff the image is a bitmap) * @param {string} fileType The MIME type of this file - * @param {string | Function} costumeNameOrNamer String or function producing the user-readable + * @param {string | Function} costumeNamer String or function producing the user-readable * name to use for the costume. Function will be called with an index in case of gif upload. * @param {ScratchStorage} storage The ScratchStorage instance to cache the costume data * @param {Function} handleCostume The function to execute on the costume object returned after * caching this costume in storage - This function should be responsible for * adding the costume to the VM and handling other UI flow that should come after adding the costume */ -const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, handleCostume) { +const costumeUpload = function (fileData, fileType, costumeNamer, storage, handleCostume) { let costumeFormat = null; let assetType = null; - const costumeNamer = typeof costumeNameOrNamer === 'string' ? - (() => costumeNameOrNamer) : costumeNameOrNamer; + const namer = typeof costumeNamer === 'string' ? + (() => costumeNamer) : costumeNamer; switch (fileType) { case 'image/svg+xml': { costumeFormat = storage.DataFormat.SVG; @@ -121,7 +121,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, case 'image/gif': { let costumes = []; const onFrame = (frameNumber, dataUrl) => { - costumeUpload(dataUrl, 'image/png', costumeNamer(frameNumber + 1), storage, costumes_ => { + costumeUpload(dataUrl, 'image/png', namer(frameNumber + 1), storage, costumes_ => { costumes = costumes.concat(costumes_); }); }; @@ -140,7 +140,7 @@ const costumeUpload = function (fileData, fileType, costumeNameOrNamer, storage, const addCostumeFromBuffer = function (dataBuffer) { const vmCostume = createVMAsset( storage, - costumeNamer(1), + namer(1), assetType, costumeFormat, dataBuffer -- GitLab