Переглянути джерело

updateMeta --> setFileMeta

Artur Paikin 7 роки тому
батько
коміт
f23b39060e
4 змінених файлів з 10 додано та 10 видалено
  1. 4 4
      src/core/Core.js
  2. 4 4
      src/core/Core.test.js
  3. 1 1
      src/plugins/Dashboard/index.js
  4. 1 1
      src/plugins/MetaData.js

+ 4 - 4
src/core/Core.js

@@ -69,7 +69,7 @@ class Uppy {
     this.i18n = this.translator.translate.bind(this.translator)
     this.getState = this.getState.bind(this)
     this.getPlugin = this.getPlugin.bind(this)
-    this.updateMeta = this.updateMeta.bind(this)
+    this.setFileMeta = this.setFileMeta.bind(this)
     this.initSocket = this.initSocket.bind(this)
     this.log = this.log.bind(this)
     this.info = this.info.bind(this)
@@ -220,7 +220,7 @@ class Uppy {
     this.setState({meta: newMeta})
   }
 
-  updateMeta (data, fileID) {
+  setFileMeta (fileID, data) {
     const updatedFiles = Object.assign({}, this.state.files)
     if (!updatedFiles[fileID]) {
       this.log('Was trying to set metadata for a file that’s not with us anymore: ', fileID)
@@ -675,8 +675,8 @@ class Uppy {
       this.calculateTotalProgress()
     })
 
-    this.on('core:update-meta', (data, fileID) => {
-      this.updateMeta(data, fileID)
+    this.on('core:update-meta', (fileID, data) => {
+      this.setFileMeta(fileID, data)
     })
 
     this.on('core:preprocess-progress', (fileID, progress) => {

+ 4 - 4
src/core/Core.test.js

@@ -717,8 +717,8 @@ describe('src/Core', () => {
         })
         .then(() => {
           const fileId = Object.keys(core.state.files)[0]
-          core.updateMeta({ foo: 'bar', bur: 'mur' }, fileId)
-          core.updateMeta({ boo: 'moo', bur: 'fur' }, fileId)
+          core.setFileMeta(fileId, { foo: 'bar', bur: 'mur' })
+          core.setFileMeta(fileId, { boo: 'moo', bur: 'fur' })
           expect(core.state.files[fileId].meta).toEqual({
             name: 'foo.jpg',
             type: 'image/jpeg',
@@ -741,8 +741,8 @@ describe('src/Core', () => {
         })
         .then(() => {
           const fileId = Object.keys(core.state.files)[0]
-          core.emit('core:update-meta', { foo: 'bar', bur: 'mur' }, fileId)
-          core.emit('core:update-meta', { boo: 'moo', bur: 'fur' }, fileId)
+          core.emit('core:update-meta', fileId, { foo: 'bar', bur: 'mur' })
+          core.emit('core:update-meta', fileId, { boo: 'moo', bur: 'fur' })
           expect(core.state.files[fileId].meta).toEqual({
             name: 'foo.jpg',
             type: 'image/jpeg',

+ 1 - 1
src/plugins/Dashboard/index.js

@@ -396,7 +396,7 @@ module.exports = class DashboardUI extends Plugin {
     }
 
     const fileCardDone = (meta, fileID) => {
-      this.core.emit('core:update-meta', meta, fileID)
+      this.core.setFileMeta(fileID, meta)
       this.core.emit('dashboard:file-card')
     }
 

+ 1 - 1
src/plugins/MetaData.js

@@ -27,7 +27,7 @@ module.exports = class MetaData extends Plugin {
     metaFields.forEach((item) => {
       const obj = {}
       obj[item.id] = item.value
-      this.core.updateMeta(obj, file.id)
+      this.core.setFileMeta(file.id, obj)
     })
   }