-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref: Streamline loading replays for hydration diffs in Issue Details #88028
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
Changes from 4 commits
8fee047
f4296be
e21280b
4c55a71
f34e5ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ import {css} from '@emotion/react'; | |
|
||
import Providers from 'sentry/components/replays/player/__stories__/providers'; | ||
import ReplayLoadingState from 'sentry/components/replays/player/replayLoadingState'; | ||
import useLoadReplayReader from 'sentry/utils/replays/hooks/useLoadReplayReader'; | ||
import useOrganization from 'sentry/utils/useOrganization'; | ||
import {useSessionStorage} from 'sentry/utils/useSessionStorage'; | ||
|
||
type Props = | ||
|
@@ -14,33 +16,50 @@ export default function ReplaySlugChooser(props: Props) { | |
|
||
const [replaySlug, setReplaySlug] = useSessionStorage('stories:replaySlug', ''); | ||
|
||
let content = null; | ||
if (replaySlug) { | ||
if (children) { | ||
content = ( | ||
<ReplayLoadingState replaySlug={replaySlug}> | ||
const input = ( | ||
<input | ||
defaultValue={replaySlug} | ||
onChange={event => { | ||
setReplaySlug(event.target.value); | ||
}} | ||
placeholder="Paste a replaySlug" | ||
css={css` | ||
font-variant-numeric: tabular-nums; | ||
`} | ||
size={34} | ||
/> | ||
); | ||
|
||
if (replaySlug && children) { | ||
function Content() { | ||
const organization = useOrganization(); | ||
const readerResult = useLoadReplayReader({ | ||
orgSlug: organization.slug, | ||
replaySlug, | ||
clipWindow: undefined, | ||
}); | ||
return ( | ||
<ReplayLoadingState readerResult={readerResult}> | ||
{({replay}) => <Providers replay={replay}>{children}</Providers>} | ||
</ReplayLoadingState> | ||
); | ||
} else if (render) { | ||
content = render(replaySlug); | ||
} | ||
return ( | ||
<Fragment> | ||
{input} | ||
<Content /> | ||
</Fragment> | ||
); | ||
} | ||
|
||
return ( | ||
<Fragment> | ||
<input | ||
defaultValue={replaySlug} | ||
onChange={event => { | ||
setReplaySlug(event.target.value); | ||
}} | ||
placeholder="Paste a replaySlug" | ||
css={css` | ||
font-variant-numeric: tabular-nums; | ||
`} | ||
size={34} | ||
/> | ||
{content} | ||
</Fragment> | ||
); | ||
if (replaySlug && render) { | ||
return ( | ||
<Fragment> | ||
{input} | ||
{render(replaySlug)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo it's kind of confusing to have two different rendering methods in this component -- I don't really know how they're used but what if they were two components ReplaySlugChooser and ReplaySlugChooserWithLoaderStuff There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll pass back over this chooser and clean it up. it's used by some |
||
</Fragment> | ||
); | ||
} | ||
|
||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just pull this out into a component with children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scttcper it gets formatted out to more line if it's a React component :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems fine