Skip to content

Refactor how we fetch the user profile - #3747

Closed
oliverlloyd wants to merge 18 commits into
mainfrom
oliver/refactor-getUser
Closed

oliverlloyd wants to merge 18 commits into
mainfrom
oliver/refactor-getUser

Conversation

@oliverlloyd

@oliverlloyd oliverlloyd commented Dec 10, 2021 •

Copy link
Copy Markdown
Contributor

What does this change?

This PR moves the logic for how we fetch the reader's profile out of App.tsx and down into the local components that use it

Why?

This is part of a wider effort to remove global state from App.tsx. See this document for more details on this.

Doesn't this mean we will fetch the profile twice?

No. Because we're using SWR, we will cache the first call and any subsequent fetch requests to the same endpoint will be served from this cache.

Why DiscussionContainer?

This PR introduces DiscussionContainer and DiscussionWhenSignedIn. This is required because you cannot conditionally call a react hook. To get around this - and arguably to separate code concerns better - we have these additional components that manage deciding if the reader is signed in and another to fetch the profile.

@github-actions

github-actions Bot commented Dec 10, 2021 •

Copy link
Copy Markdown

Size Change: +675 B (0%)

Total Size: 3.13 MB

Filename Size Change
dotcom-rendering/dist/frontend.server.js 2.48 MB +418 B (0%)
dotcom-rendering/dist/react.js 139 kB +88 B (0%)
dotcom-rendering/dist/react.legacy.js 145 kB +169 B (0%)
ℹ️ View Unchanged
Filename Size
dotcom-rendering/dist/101.js 21.1 kB
dotcom-rendering/dist/101.legacy.js 21.1 kB
dotcom-rendering/dist/195.js 1.11 kB
dotcom-rendering/dist/195.legacy.js 1.23 kB
dotcom-rendering/dist/atomIframe.js 1.87 kB
dotcom-rendering/dist/atomIframe.legacy.js 2.13 kB
dotcom-rendering/dist/bootCmp.js 7.5 kB
dotcom-rendering/dist/bootCmp.legacy.js 11.1 kB
dotcom-rendering/dist/braze-web-sdk-core.js 36.1 kB
dotcom-rendering/dist/braze-web-sdk-core.legacy.js 36.1 kB
dotcom-rendering/dist/cmp.js 7.78 kB
dotcom-rendering/dist/coreVitals.js 4.03 kB
dotcom-rendering/dist/coreVitals.legacy.js 4.31 kB
dotcom-rendering/dist/dynamicImport.js 2.99 kB
dotcom-rendering/dist/dynamicImport.legacy.js 3.27 kB
dotcom-rendering/dist/EditionDropdown.js 685 B
dotcom-rendering/dist/EditionDropdown.legacy.js 694 B
dotcom-rendering/dist/elements-CalloutBlockComponent.js 4.15 kB
dotcom-rendering/dist/elements-CalloutBlockComponent.legacy.js 4.46 kB
dotcom-rendering/dist/elements-DocumentBlockComponent.js 571 B
dotcom-rendering/dist/elements-DocumentBlockComponent.legacy.js 602 B
dotcom-rendering/dist/elements-InstagramBlockComponent.js 434 B
dotcom-rendering/dist/elements-InstagramBlockComponent.legacy.js 452 B
dotcom-rendering/dist/elements-InteractiveBlockComponent.js 2.96 kB
dotcom-rendering/dist/elements-InteractiveBlockComponent.legacy.js 3.1 kB
dotcom-rendering/dist/elements-InteractiveContentsBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-InteractiveContentsBlockComponent.legacy.js 1.95 kB
dotcom-rendering/dist/elements-MapEmbedBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-MapEmbedBlockComponent.legacy.js 1.94 kB
dotcom-rendering/dist/elements-RichLinkComponent.js 3.26 kB
dotcom-rendering/dist/elements-RichLinkComponent.legacy.js 3.3 kB
dotcom-rendering/dist/elements-SpotifyBlockComponent.js 1.8 kB
dotcom-rendering/dist/elements-SpotifyBlockComponent.legacy.js 1.86 kB
dotcom-rendering/dist/elements-VideoFacebookBlockComponent.js 1.88 kB
dotcom-rendering/dist/elements-VideoFacebookBlockComponent.legacy.js 1.94 kB
dotcom-rendering/dist/elements-VineBlockComponent.js 579 B
dotcom-rendering/dist/elements-VineBlockComponent.legacy.js 594 B
dotcom-rendering/dist/elements-YoutubeBlockComponent.js 2.57 kB
dotcom-rendering/dist/elements-YoutubeBlockComponent.legacy.js 2.7 kB
dotcom-rendering/dist/embedIframe.js 1.88 kB
dotcom-rendering/dist/embedIframe.legacy.js 2.13 kB
dotcom-rendering/dist/ga.js 3.88 kB
dotcom-rendering/dist/ga.legacy.js 4.13 kB
dotcom-rendering/dist/GetMatchStats.js 3.29 kB
dotcom-rendering/dist/GetMatchStats.legacy.js 3.36 kB
dotcom-rendering/dist/guardian-braze-components-banner.js 9.78 kB
dotcom-rendering/dist/guardian-braze-components-banner.legacy.js 9.79 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.js 6.56 kB
dotcom-rendering/dist/guardian-braze-components-end-of-article.legacy.js 6.57 kB
dotcom-rendering/dist/MostViewedFooterData.js 6.27 kB
dotcom-rendering/dist/MostViewedFooterData.legacy.js 6.36 kB
dotcom-rendering/dist/MostViewedRightWrapper.js 3.89 kB
dotcom-rendering/dist/MostViewedRightWrapper.legacy.js 4.07 kB
dotcom-rendering/dist/newsletterEmbedIframe.js 1.83 kB
dotcom-rendering/dist/newsletterEmbedIframe.legacy.js 2.08 kB
dotcom-rendering/dist/OnwardsLower.js 9.62 kB
dotcom-rendering/dist/OnwardsLower.legacy.js 9.86 kB
dotcom-rendering/dist/OnwardsUpper.js 14 kB
dotcom-rendering/dist/OnwardsUpper.legacy.js 14.3 kB
dotcom-rendering/dist/ophan.js 7.17 kB
dotcom-rendering/dist/ophan.legacy.js 7.36 kB
dotcom-rendering/dist/relativeTime.js 2.41 kB
dotcom-rendering/dist/relativeTime.legacy.js 2.67 kB
dotcom-rendering/dist/sentry.js 677 B
dotcom-rendering/dist/sentry.legacy.js 687 B
dotcom-rendering/dist/sentryLoader.js 4.74 kB
dotcom-rendering/dist/sentryLoader.legacy.js 7.69 kB
dotcom-rendering/dist/shimport.js 2.75 kB
dotcom-rendering/dist/shimport.legacy.js 2.76 kB
dotcom-rendering/dist/SignInGateMain.js 1.82 kB
dotcom-rendering/dist/SignInGateMain.legacy.js 1.85 kB

compressed-size-action

@oliverlloyd

Copy link
Copy Markdown
Contributor Author

@oliverlloyd
oliverlloyd marked this pull request as draft December 10, 2021 17:35
@oliverlloyd

Copy link
Copy Markdown
Contributor Author

Closing now that we've completed this work via separate PRs

@shtukas
shtukas deleted the oliver/refactor-getUser branch February 1, 2023 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant