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

Fix stale data when clicking back button to stateless app #2565

Merged
merged 15 commits into from
Oct 17, 2024

Conversation

adamhaeger
Copy link
Contributor

@adamhaeger adamhaeger commented Oct 10, 2024

Description

Disabling cache of formdata when in a stateless app.

Testing:

  1. Start frontend locally
  2. Follow instructions in issue, log in with one of the users below
  3. Switch to local frontend code with devtools after logging in.
  4. Continue with instructions, and verify that the actual scenario now works.

Test users:

d-uka-2;894xt
d-duell-2;kf84d
d-viser-1;dyryx
d-felt-1;rx2c2
d-glis-2;nqbsk
d-kutt-1;vsxr7

Related Issue(s)

Verification/QA

This is a very custom implementation from UDIR that we cant easily test.

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

@adamhaeger adamhaeger added the kind/bug Something isn't working label Oct 10, 2024
queryKey,
queryFn: url ? () => fetchFormData(url, options) : skipToken,
enabled: true,
gcTime: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Skal ikke hindre merge, men bare noen tanker 😄

Kunne det vært nyttig å sette staleTime i stedet for gcTime for at senere fetches skal hente med stale-while-revalidate?

En annen tanke er også at isStateless-variabelen har noe å si hvor hva som returneres, og burde da kanskje være i queryKey-en? Typ [...queryKey, { isStateless }] eller noe sånn at man har forskjellig queryKey for stateful og stateless.

Copy link
Contributor Author

@adamhaeger adamhaeger Oct 10, 2024

Choose a reason for hiding this comment

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

Hvis vi har har stale-while-revalidate, vil vi ikke da vise gammel data til vi har fått ny data? Det vil vi ikke i det tilfellet denne buggen kommer fra ihvertfall siden de bruker denne dataen til å vise om man har startet på skjemaet eller ikke. Vi ville da vist siden med "start nytt skjema" først, og så "Fortsett på skjema" når dataen er lastet.

Litt usikker på hva vi vinner på å ha isStateless i queryKey? At vi trigger query når isStateless forandrer seg?

Copy link
Member

Choose a reason for hiding this comment

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

Query keyen bør allerede være forskjellig når man er i stateless siden query keyen er basert på url-en den henter ifra. For stateful er det url til data-elementet, men for stateless er det en annen url som refererer til data-typen som brukes i stateless (siden det ikke finnes noe data element da)

Copy link

sonarcloud bot commented Oct 17, 2024

@adamhaeger adamhaeger merged commit 530b0f3 into main Oct 17, 2024
9 checks passed
@adamhaeger adamhaeger deleted the fix/2564-back-button-stale-data branch October 17, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UDIR: Stale data on back button navigation
3 participants