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

Fix: loading forms in Firefox private browsing mode - #324

Merged
eyelidlessness merged 2 commits into
enketo:qa/3.0.2-prefrom
eyelidlessness:fix/323-firefox-private-browsing-online
Oct 13, 2021
Merged

Fix: loading forms in Firefox private browsing mode#324
eyelidlessness merged 2 commits into
enketo:qa/3.0.2-prefrom
eyelidlessness:fix/323-firefox-private-browsing-online

Conversation

@eyelidlessness

Copy link
Copy Markdown
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

@lognaturel lognaturel left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread public/js/src/module/last-saved.js Outdated
* @param {IsLastSaveEnabledOptions} [options]
*/
export const isLastSaveEnabled = ( survey ) => {
export const isLastSaveEnabled = ( survey, options = { checkStoreAvailability: true } ) => {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

seadowg commented Oct 11, 2021

Copy link
Copy Markdown

@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

yanokwa commented Oct 12, 2021

Copy link
Copy Markdown
Member

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

@lognaturel

lognaturel commented Oct 12, 2021

Copy link
Copy Markdown
Contributor

@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

yanokwa commented Oct 12, 2021

Copy link
Copy Markdown
Member

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
@eyelidlessness
eyelidlessness force-pushed the fix/323-firefox-private-browsing-online branch from cb86018 to 127b099 Compare October 12, 2021 20:09
@eyelidlessness
eyelidlessness merged commit aeb03bd into enketo:qa/3.0.2-pre Oct 13, 2021
@eyelidlessness eyelidlessness mentioned this pull request Oct 20, 2021
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