Skip to content

Commit

Permalink
style(js): Small code style cleanup in stacktracePreview (#36388)
Browse files Browse the repository at this point in the history
Co-authored-by: Alberto Leal <[email protected]>
  • Loading branch information
evanpurkhiser and dashed authored Jul 7, 2022
1 parent 0605786 commit 763802f
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions static/app/components/stacktracePreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import findBestThread from './events/interfaces/threads/threadSelector/findBestT
import getThreadStacktrace from './events/interfaces/threads/threadSelector/getThreadStacktrace';

const REQUEST_DELAY = 100;
const HOVERCARD_DELAY = 400;
const HOVERCARD_CONTENT_DELAY = 400;

export const STACKTRACE_PREVIEW_TOOLTIP_DELAY = 1000;

Expand Down Expand Up @@ -137,9 +137,10 @@ function StackTracePreview(props: StackTracePreviewProps): React.ReactElement {
return;
}

loaderTimeoutRef.current = window.setTimeout(() => {
setLoadingVisible(true);
}, HOVERCARD_DELAY);
loaderTimeoutRef.current = window.setTimeout(
() => setLoadingVisible(true),
HOVERCARD_CONTENT_DELAY
);

try {
const evt = await api.requestPromise(
Expand Down Expand Up @@ -176,26 +177,23 @@ function StackTracePreview(props: StackTracePreviewProps): React.ReactElement {
delayTimeoutRef.current = undefined;
}, []);

// Not sure why we need to stop propagation, maybe to to prevent the hovercard from closing?
// If we are doing this often, maybe it should be part of the hovercard component.
const handleStackTracePreviewClick = useCallback((e: React.MouseEvent) => {
e.stopPropagation();
}, []);
// Not sure why we need to stop propagation, maybe to prevent the
// hovercard from closing? If we are doing this often, maybe it should be
// part of the hovercard component.
const handleStackTracePreviewClick = useCallback(
(e: React.MouseEvent) => void e.stopPropagation(),
[]
);

const stacktrace = useMemo(() => {
if (event) {
return getStacktrace(event);
}
return null;
}, [event]);
const stacktrace = useMemo(() => (event ? getStacktrace(event) : null), [event]);

return (
<span
className={props.className}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
<StyledHovercard
<StacktraceHovercard
body={
status === 'loading' && !loadingVisible ? null : status === 'loading' ? (
<NoStackTraceWrapper onClick={handleStackTracePreviewClick}>
Expand Down Expand Up @@ -233,14 +231,14 @@ function StackTracePreview(props: StackTracePreviewProps): React.ReactElement {
tipColor="background"
>
{props.children}
</StyledHovercard>
</StacktraceHovercard>
</span>
);
}

export {StackTracePreview};

const StyledHovercard = styled(Hovercard)<{state: 'loading' | 'empty' | 'done'}>`
const StacktraceHovercard = styled(Hovercard)<{state: 'loading' | 'empty' | 'done'}>`
/* Lower z-index to match the modals (10000 vs 10002) to allow stackTraceLinkModal be on top of stack trace preview. */
z-index: ${p => p.theme.zIndex.modal};
width: ${p => {
Expand Down

0 comments on commit 763802f

Please sign in to comment.