Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Fix: loading forms in Firefox private browsing mode #324

Conversation

eyelidlessness
Copy link
Contributor

Fixes enketo/enketo#1050. In online mode, IndexedDB initialization failure is ignored. In the event of failure, references to last-saved fall back to the form's model, the same way it would if IndexedDB was available but no last-saved record were stored.

@seadowg seadowg self-requested a review October 11, 2021 09:18
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

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

Verified:

  • test cases cover every attempt at accessing the store in the context of last-saved
  • only applies in online mode (since offline mode requires store for offline things)

To confirm -- offline mode in Firefox private mode always has and continues to fail with a cryptic error message?

*/
export const isLastSaveEnabled = ( survey ) => {
export const isLastSaveEnabled = ( survey, options = { checkStoreAvailability: true } ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This has now changed from "does the form specify that last-saved is enabled" to "Enketo should use last-saved functionality". I think that's ok and the naming is still accurate enough but did want to flag that the change in semantics gave me pause.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not thrilled about this signature change, this was mostly a pragmatic way to a quick fix. How would you feel about breaking this into two functions?

  • hasLastSavedInstance: the previous isLastSavedEnabled behavior
  • isLastSavedEnabled: store.available && hasLastSavedInstance(survey)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, now that I look at it, I think the encryption check should be in isLastSavedEnabled rather than hasLastSavedInstance as well. It doesn't make sense for an encrypted survey to reference a last-saved instance, but in the event it does that presumably should also be populated with the model defaults.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a huge deal but that latest suggestion does seem nicer to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@lognaturel
Copy link
Contributor

@seadowg I see you're also lined up to review. I'm pretty confident that the approach is reasonable but happy for you to take a look if you want to make sure!

@seadowg seadowg removed their request for review October 11, 2021 16:52
@seadowg
Copy link

seadowg commented Oct 11, 2021

@lognaturel don't want to hold this up, and I might not get a chance to review before the end of my day today. I'll remove myself as a reviewer.

@yanokwa
Copy link
Member

yanokwa commented Oct 12, 2021

@eyelidlessness Remember that this PR needs to be QAed, so let's merge it into a new QA branch when you are ready.

@lognaturel
Copy link
Contributor

lognaturel commented Oct 12, 2021

@yanokwa so you want a branch on mainline in order for an image to be built, right? If so, might I suggest @eyelidlessness simply push his branch to upstream? Then this PR can be merged to master once it's validated.

@yanokwa
Copy link
Member

yanokwa commented Oct 12, 2021

Ordinarily, that'd work, but in this case we want to QA all the other changes that are coming in from transformer. I supposed we could add them to this PR, but seems do stuff in a QA branch.

@eyelidlessness eyelidlessness changed the base branch from master to qa/3.0.2-pre October 12, 2021 18:28
Also tests, and ensures, that last-saved instances are populated with model defaults on encrypted surveys
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading forms in Firefox private browsing mode fails
4 participants