Procházet zdrojové kódy

Compare file.id instead of the whole object (#1672)

Artur Paikin před 5 roky
rodič
revize
09178ae134
1 změnil soubory, kde provedl 4 přidání a 2 odebrání
  1. 4 2
      packages/@uppy/provider-views/src/index.js

+ 4 - 2
packages/@uppy/provider-views/src/index.js

@@ -323,7 +323,9 @@ module.exports = class ProviderView {
 
   isChecked (file) {
     const { currentSelection } = this.plugin.getPluginState()
-    return currentSelection.some((item) => item === file)
+    // comparing id instead of the file object, because the reference to the object
+    // changes when we switch folders, and the file list is updated
+    return currentSelection.some((item) => item.id === file.id)
   }
 
   /**
@@ -403,7 +405,7 @@ module.exports = class ProviderView {
     const { currentSelection } = this.plugin.getPluginState()
     if (this.isChecked(file)) {
       this.plugin.setPluginState({
-        currentSelection: currentSelection.filter((item) => item !== file)
+        currentSelection: currentSelection.filter((item) => item.id !== file.id)
       })
     } else {
       this.plugin.setPluginState({