collect icon indicating copy to clipboard operation
collect copied to clipboard

Do not update forms while they are being filled out

Open grzesiek2010 opened this issue 4 months ago • 5 comments

Closes #6232 Closes #6452

Why is this the best possible solution? Were any other approaches considered?

This pull request addresses two scenarios:

  1. Preventing forms from being opened during the forms update process.
  2. Preventing form updates during form filling.

To handle both cases, I used the ChangeLock mechanism as recommended in the issue. The flow is as follows:

  1. If a user attempts to open a form, we check whether the forms database is locked and displays an error. This differs slightly from the original approach, which suggested using a progress dialog to wait for the update process to finish. I believe this simpler solution is sufficient for now and aligns with other errors that can occur before opening a form (which we handle in FormUriActivity). The error will look like this: image We might want to refine the message a bit. @alyblenkin, maybe you could suggest something?

  2. If the database isn't locked, we lock it and open the form.

  3. Any form updates triggered during form filling are blocked since the forms database remains locked.

  4. Once the form is closed, we unlock the database, allowing any pending form updates to proceed.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

As mentioned above, I used the mechanism of locking the forms database to control whether a forms update can proceed or if a form can be opened. However, I find this approach somewhat risky. I’m concerned about scenarios where the database may not be properly unlocked after exiting a form (since it must remain locked during form filling to prevent updates). In such cases, if a user tries to open another form, it could fail because the database is still locked. While this shouldn't happen based on my understanding, unexpected issues can always occur. I can go over the details of this process on a call if you'd like.

If you find testing this pull request difficult, as it may not be clear when the forms update process starts or ends, let me know, and I can add some visual indicators specifically for testing.

Do we need any specific form for testing your changes? If so, please attach one.

No.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • [x] added or modified tests for any new or changed behavior
  • [x] run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • [x] added a comment above any new strings describing it for translators
  • [x] added any new strings with date formatting to DateFormatsTest
  • [x] verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • [x] verified that any new UI elements use theme colors. UI Components Style guidelines

grzesiek2010 avatar Oct 03 '24 19:10 grzesiek2010