#Updte storage

1 messages · Page 1 of 1 (latest)

cold rampart
#

Hi,

I have an initStorage when the page load.
initStorage: () => { storeValue('adchaseStorage', get_data.data.map(item => { return { adchaseId: item.adc_id, selectionId: item.SELECTION_sel_id, score: null, label: null, } })); }

It store 10 items in the storage.

When I filter data, I wish to upload the storage with the good number of items.
So I call a updateStorage with dataList as an array

    ```
updateStorage: (dataList) => {
          storeValue('adchaseStorage', dataList.map(item => {
        return {
            adchaseId: item.adc_id,
            selectionId: item.SELECTION_sel_id,
            score: null,
            label: null,
        }
    }));
      }```

It doesn't work.
What did I do wrong on the update function? 😦

spark valeBOT
#

Hi There!
Thanks for reaching out to us. One of our engineers will be with you shortly.

If you are stuck with an issue/error, please help us with following information.

  1. Which version of Appsmith are you on?
  2. Provide screenshots/screen recordings of the original error/code snippet.
  3. Add details about your use case and provide steps to reproduce the issue, if
    possible.
spark valeBOT
#

Hi! Please elaborate on your use case. When are you calling the update function?
Could you share a loom.com screen recording to show the issue in action?

cold rampart
#

As I refering to the index of my list of data, I need to update the storage with the new list everytime I filter the data.
initial list {item0, item1, item2, item3}
list can become {item0} after a filter with item0 is the previous Item3 from the initial list

so the index was 3 for this item and become 0 with the filter.
As i'm working with index in my code, I need to update the storage with the right items.
Or should I keep all item and try to find the item with an ID?