Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty instanceDir if a user quits the identity dialog #6020

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Mar 16, 2024

Closes #5921

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

I think adding the exit method to IdentityPromptViewModel is a good solution because it is consistent with what we does for another ViewModel (FormEntryViewModel).

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?

This should only fix the issue and have no side effects.

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

Any form with Enumerator identification

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:

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

@grzesiek2010 grzesiek2010 marked this pull request as ready for review April 23, 2024 19:48
@@ -72,4 +75,8 @@ private static boolean userIsValid(String user) {
public String getFormTitle() {
return formName;
}

public void exit() {
FileUtils.purgeMediaPath(instanceFolder);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there's more of a shared place we can handle this clean up. It looks like you can't call FormSaveViewModel#ignoreChanges in this scenario as the FormSaveViewModel won't know about the FormController yet.

Where does this instance folder actually get created?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this instance folder actually get created?

It's here https://github.com/getodk/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/activities/FormFillingActivity.java#L1960

I'm wondering if there's more of a shared place we can handle this clean up.

I was also thinking about that and I'm aware of the fact that this solution is maybe not perfect but I wasn't able to find a better one. If there is a form that requires identity we don't even save formController before passing it formControllerAvailable so it's not available in other places to read the dir parth and remove.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could pull a chunk of the code in FormSaveViewModel#ignoreChanges out into a use case that can be called in both places? Thinking about that

I'm actually wondering whether if the clean up code in ignoreChanges should just be called whenever we end form filling? It might be that we could start thinking of FormSessionRepository more like one of our data services and move logic like that in there (it could be triggered from clear for example).

Maybe I'm thinking about this incorrectly, but the bug doesn't feel high priority enough to not take these opportunities to restructure while fixing it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FormSaveViewModel as the name suggest is responsible for saving-related operations. using it in this case where we don't even enter the form-filling view sounds a little bit weird to me. Do you really think it would be a better place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more meaning the shared code would move out FormSaveViewModel to a separate use case rather than using it in both places.

@@ -72,4 +75,8 @@ private static boolean userIsValid(String user) {
public String getFormTitle() {
return formName;
}

public void exit() {
FileUtils.purgeMediaPath(instanceFolder);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could pull a chunk of the code in FormSaveViewModel#ignoreChanges out into a use case that can be called in both places? Thinking about that

I'm actually wondering whether if the clean up code in ignoreChanges should just be called whenever we end form filling? It might be that we could start thinking of FormSessionRepository more like one of our data services and move logic like that in there (it could be triggered from clear for example).

Maybe I'm thinking about this incorrectly, but the bug doesn't feel high priority enough to not take these opportunities to restructure while fixing it.

@grzesiek2010 grzesiek2010 requested a review from seadowg May 15, 2024 21:30
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grzesiek2010 grzesiek2010 force-pushed the COLLECT-5921 branch 3 times, most recently from 1a13fab to ded9bd9 Compare November 18, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Empty file of Identify user form in the directory created without saving the form
2 participants