How can I disable a component for certain period of time and store it so that if someone reopens application timer do not get reset

I am trying for days please someone help me.
How can I disable a component ( button ) for certain period of time and store it so that it runs in background means when user reopens application. timer do not get reset.

You can use the [seconds since 1970] block in the Devices drawer. When you disable the button, set a variable called disableTimestamp to [seconds since 1970]. It will need to be a stored variable so that it gets saved to the device.

Then, when the screen opens, check to see if [seconds since 1970] - disableTimestamp ≥ [amount of time to disable button]. If so, allow enable the button.

I did this and things are also working but when i press back or I re login the button automatically enables even if I set the timer…what can I do so that buttons work in background or work even if I press back or do something… please help with this

You should not be using the Timer1's Time in seconds block. I suggested that you need to check if a value is greater than or equal to the [amount of time to disable button]. So if you want it disabled for an hour, you would check if it’s ≥ 3600 because 60 minutes * 60 seconds = 3600 seconds.

With this method, you do not need a Timer component at all.

Also, I suggested a stored variable and you instead used an app variable. That’s not correct. Only a stored variable will save the value after the app closes.

Screenshot 2023-05-27 132343

I did as you said things are also working but when i press back and reopens that screen it does not store and it automatically enables the button even when your time period is not over? Please help me fix this.

and i am doing things on live test on device.

Okay, so when the screen opens, it’s going to set the button’s “disabled” property to whatever you have it set to as the default. Try adding an else section to the if block and have the else section set ad1’s Disabled to true.

Can you share a link to your project?

https://x.thunkable.com/copy/e84594f95238e30eb1c5a13998e82c09

This is link

I did as you said still not working sir.

You didn’t add the change I suggested (an else section) and you’re also testing it with a value of 2. Two seconds might not be enough time to really test this.

Also, any time you use a stored variable, you have to check if it’s null and give it a starting value.

This works for me: Thunkable (see the first screen)

Each time I press Live Test, it displays the elapsed time and enables/disables the button. However, this will not check to see if the time has elapsed while the app is open. So you’d need to add a loop to check that.

Sir kudos to you.
:sob::pinched_fingers:t2: You helped me alot.
I have no words to express.
Thankyou so much sir.
I changed value from 5 to 100 and things worked.

1 Like

Sir sorry to bother you again. But things are working but there is one problem happing I don’t why…so as you did I did the same but the problem is arising that when i click on ad1 buttons disables ok but when i press back and then reopens the same screen then rest of the buttons automatically disabled even when i don’t click on them.


Sorry I didn’t attached ad1 blocks

You need to use a different variable for each timestamp. Each button has to have its own.

So you are saying there are 5 buttons so I have to make 5 different - stored disable timestamp for each button and use them?

Yes. Because the user will press them at different times so each one should have its own timer, right?

Sir

I don’t know why I had 3-4 projects running in my account yesterday means I opened different projects to view. And also there was my project in which I was working. Sir I don’t know but today when I tired to open my project there is no project.I don’t know zero projects are showing…Help me fix this

I’m not going to be able to help you with that but Thunkable Staff should be able to.

Try signing out and signing back in. Is it possible you have two Thunkable accounts?

Also, if you can, post a link to the project here.

I have only one account I tired to logout and login but didn’t worked

Where can I contact thunkable for help?

If you have a Pro account, you can use the chat icon inside a project.

If not, I’m not sure.