FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
115 stars 19 forks source link

Timer On End Event called by Reset Timer #3600

Open technoclectic opened 1 month ago

technoclectic commented 1 month ago

Can we access your project?

Current Behavior

When the timer ends and the OnTimerEnd action is fired I need to reset that timer and run it again. So I call a Reset Timer action to set the timer again to the time that I want followed by a Start Timer to start the timer.

The Reset Timer action however triggers the OnTimerEnd to fire again. This means that all actions in the chain are duplicated if you are running a timer more than 1 time.

So I need to know how to detect if it is the true timer ending (the timer hits 00:00) OR if it is the OnTimerEnd triggered by the Reset Timer.

Expected Behavior

OnTimerEnd to only be called when the timer actually ends. Said another way, the Reset Timer action should NOT fire the OnTimerEnd event

Steps to Reproduce

  1. New page
  2. Add timer
  3. Add page state variable as a counter and bind a text field to it so that you can see what's happening.
  4. Add the following actions to timer's OnTimerEnd event. 4a. Update Page State variable by +1 4b. Reset Timer to 10s 4c. Start Timer

Reproducible from Blank

Bug Report Code (Required)

IT4ClefqwItOpbxJ7qX2bsEw+SoUKVAjRYE70e5HdxEaN5PRCJkqe/fOTERpXsSlTFV+OmKkjWoW0ejni/DhUuw3PU6ZY4hhyapySTrgXk65R7XTFJWgZ2hfHe9jI3K05MONuh14KsRfdCEB2jn3fe6iYA3vQaX6Omo4Da/LZO4=

Visual documentation

https://support.technoclectic.com/conversations/51e675d5-5364-53e9-95e1-e658e5fa3079

Environment

- FlutterFlow version: 4.1.82
- Platform: Desktop app
- Browser name and version: Local Run testing
- Operating system and version affected: All versions

Additional Information

This unexpected behavior is causing many delays in my project. Trying to find workarounds or ways to detect if the OnTimerEnd event is called by the timer reaching 00:00 ms versus the Reset Timer action calling it. Is there a way to add a boolean to the Reset Timer say "don't trigger OnTimerEnd" when resetting?

technoclectic commented 1 month ago

Here is a workaround: Add page state variable type: boolean Set to False by default Add a conditional first step in Action chain of the OnTimerEnd event Set the condition to the Page State variable In the true branch update your counter variable to decrement by 1 (-1) In the false branch put your logic.

this is a very inelegant workaround and shouldn't be considered a solution.

Alezanello commented 1 month ago

Hello!

I was able to get the counter running smoothly without the need for the decrement workaround you suggested. The key is to adjust the order of operations slightly:

Instead of:

  1. Update page state
  2. Reset timer
  3. Start timer

You should try:

  1. Reset timer
  2. Update page state
  3. Start timer

    image.png

This sequence should work without any issues!

Alezanello commented 1 month ago

Example: https://app.flutterflow.io/run/mGolZzaYGPwWA5z4ywxw

technoclectic commented 1 month ago

I’m unable to load this project, not sure if it has expired or what. I will try your solution to move the action shortly and let you know. On Aug 13, 2024 at 14:33 -0700, Alezanello @.***>, wrote:

Example: https://app.flutterflow.io/run/mGolZzaYGPwWA5z4ywxw — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

technoclectic commented 1 month ago

Hi, I notice that you don’t have any type of looping or conditional actions in your code flow. This would be needed to accurately represent my use case. I am attaching what I have that is working and I thought was laid out in the video on the issue.

You will notice 3 conditional blocks.

  1. Determines if this is a duplicate and should be ignored (the workaround)
  2. Only runs on the initial counter (3,2,1,Go!) and has a roundCounter of 0. There is no increment in this conditional block.
  3. Should run for each subsequent iteration and increments the roundCounter on each completion until the rounds variable is matched.
Screenshot 2024-08-15 at 11 39 30

I’m happy to drill into any of these actions but the result was the same when I tried your suggestion.

Thanks Gary On Aug 13, 2024 at 14:24 -0700, Alezanello @.***>, wrote:

Hello! I was able to get the counter running smoothly without the need for the decrement workaround you suggested. The key is to adjust the order of operations slightly: Instead of:

  1. Update page state
  2. Reset timer
  3. Start timer

You should try:

  1. Reset timer

  2. Update page state

  3. Start timer

This sequence should work without any issues! — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue.

technoclectic commented 3 weeks ago

Issue is still open. Getting warnings that it’s stale? On Aug 22, 2024 at 18:54 -0700, github-actions[bot] @.***>, wrote:

This issue is stale because it has been open for 7 days with no activity. If there are no further updates, a team member will close the issue. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Alezanello commented 2 weeks ago

Hello,

I apologize for the late response. Does this issue still persist, or was it fixed in the latest FlutterFlow updates?

technoclectic commented 2 weeks ago

I am away on holiday at the moment and cannot check. Please leave the issue open until I have an opportunity to review. On Sep 3, 2024 at 16:04 +0300, Alezanello @.***>, wrote:

Hello,

I apologize for the late response. Does this issue still persist, or was it fixed in the latest FlutterFlow updates? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

technoclectic commented 1 week ago

I don't see that anything has changed for the timer firing the ontimerend event on reset.