I am working on a local language puzzle game app …& I need to save response in Custom States List.
The problem is I can’t save duplicate values in the list as bubble doesn’t allow duplicates in custom state list. It automatically removes the duplicates.
Bubble forum suggests having a new thing in database for each response to get unique values, which is very painful way.
In my app, I need to get user’s responses (0 to 5) from each repeating group’s cell and save in the custom state list…lastly save to DB.
The RG will have maximum 200 cells…that means i need to collect 200 responses. All response values will be between 0 to 5. So ofcourse there will be duplicate values. How do I save these responses locally? Because writing in DB each time lowers the game performance and user interest.
I also want to modify this list of user’s responses, when user goes back to previous cells of a repeating group and changes his selection.
I spent too much time in finding a way, but I couldn’t solve it. Please help.
If a plugin can potentially solve this I am willing to contribute, If it helps me to save & modify duplicate values in custom state list… because I don’t want to save in database on each & every click.
I think you can solve this problem by using local storage. Bubble uses local storage extensively to enhance the usability of the Bubble platform and make it more user friendly. Local storage can be stored and retrieved through one line of javascript. There are also existing free plugins that will allow you to use local storage.
In this way you don’t have to go to the database and you don’t have to worry about list constraints (of which there is no work-around that allows you have duplicates). I would suggest using the Toolbox plugin to set and retrieve these values via javascript using the lines below:
var result = window.localStorage.getItem(properties.key);
However, if you wanted to write a plugin to use local storage (and for some reason you didn’t want to use one of the free ones already available), it would look something like this:
Local storage will allow you to track game states on the client quickly and then you could save these values to your database using a “save point” in the case you wanted to retain the values in the next game session.
Hey @bubble.trouble many many thanks for such a discriptive explanation. Actually, I am not fully aware about bubble capabilities…and I will explore more about local storages as you suggested.
Hey @bubble.trouble I tried using local storage as you suggested,
Installed Toolbox plugin, named function
Ran your JS code in workflow to save values
Values are getting saved in local storage as intended (index-wise), I am also able to change them index-wise successfully.
Now comes the headache
I couldn’t get those saved values in bubble. I tried calling that test function in run javascript, i tried localstorage.getitem…i also explored information about getting those values in bubble…but i couldn’t. Its day 3, so I decided to ask for help.
I am sure that I was writing wrong syntaxes (I also used the ones you gave in your earlier reply). How can I get that values list in bubble and save to database? Kindly help me with the correct code.
Thank you.