Hey. We are building a digital helper tool for trainings meant for professionals and leaders of the companies (who are a critical bunch). I’ve got a problem, that makes my app look very unprofessional (and buggy). I have been looking for a solution and haven’t find it. Maybe some of you guys can help me out…
The issue is with database calls. Since my app does them often and a lot, some fail for some reason and reveal some very nasty bugs.
In the app we have several buttons that open popups. These buttons are allowed at some point and restricted at others, depending on where the users are. We are controlling the availability with credits. For example: you have 2 credits so you can open 2 popups. Every time you open one, you lose one credit. When you run out of credits, you cannot open any of them any more.
Each user has “credits” variable that is always checked before allowing or disallowing the button click that triggers the popup open. The problem is sometimes this call doesn’t go through and the user is allowed to click the button even though he has run out of credits (and therefor go into minus with the credits).
The same issue happens in other places. We mark the buttons that the user has clicked in different color (using conditionals). For that we have another table called “opened popups”. So each time user clicks on a button (and opens a popup) we create an entry in the “opened popups” with variables “user” and “opened popup”. Now to set the color of the button, we check whether this popup has been opened by the user or not and set the color. Quite often this call also doesn’t go through leaving button color as if it is not opened yet, but it is.
So the question is - how to make database calls more reliable? With regular soft I can wait for the answer and prevent anything from happening before the call gets through (and repeat the call until I have the response). Here I haven’t found a way to do that. Am I missing something?
This will be hard without knowing exactly your setting.
One thing you can consider, is to use state instead of calling DB each time.
Store the Current user credit into a state. And each time a user open a popup, update this state and DB too. But make your condition to use the state. So if a DB call take too long to complete, this should not be the case with the state. Also, you may consider a lot of differents actions to prevent this kind of behavior. But without knowing your setting, this is harder to tell you what you can improve.
What kind of information would I need to give to help you help me?
States is a good idea. Since it is more critical to not allow user to do stuff without credits, I can leave getting new credits to recurring database call (every 5 sec for example) and leave the allowance of button clicks only to the states. I think that would improve it a lot.
What other possible “different actions” do you mean?
This can be in order things are done for example.
If you have a few flows step that process before updating the DB credit, this may left enough time to user to open another popup.
You can also use “Reset data” and set the data on a group. This way, the data will be fetched to server.
I wouldn’t rely on states for this as states do go away ( are temporary ) once the page is closed, or the user navigates to a different page on your app…
There is a plug-in that helps with that issue “Env Variables”
I bought it a couple months ago, and only used it once and was a little unhappy I purchased it…HOWEVER, I came to a point in my app today that I needed it again and noticed the updates and it is more powerful before…
Basically it allows you to use the element on your page and it stores information just like a custom state would, but any page you place the element on it will communicate and share that information…so if the user does navigate to a different page on the app, you will not lose that information…it can also allow you to modify the data and save it to database…even do a auto bind I think
I would definitely look into it, it is only $16, so definitely in my mind worth it.
Another idea, would be to add a data field that is a Yes/No ( maybe “is_over_credit_limit” ) and use that for the conditionals etc…and use the custom states to track the number and on page load search the D.B. for the number to add to custom state with a conditional workflow event that when the custom state equals zero make a change to thing to turn the Yes/NO field to YES.