express rerender by incrementing counter
This commit is contained in:
parent
b75cf1fba6
commit
05ca43bd91
|
|
@ -94,7 +94,7 @@ const ExpandableAttachment: React.FunctionComponent<ExpandableAttachmentProps> =
|
||||||
|
|
||||||
export const AttachmentsTab: React.FunctionComponent<{
|
export const AttachmentsTab: React.FunctionComponent<{
|
||||||
model: MultiTraceModel | undefined,
|
model: MultiTraceModel | undefined,
|
||||||
revealedAttachment?: AfterActionTraceEventAttachment,
|
revealedAttachment?: [AfterActionTraceEventAttachment, number],
|
||||||
}> = ({ model, revealedAttachment }) => {
|
}> = ({ model, revealedAttachment }) => {
|
||||||
const { diffMap, screenshots, attachments } = React.useMemo(() => {
|
const { diffMap, screenshots, attachments } = React.useMemo(() => {
|
||||||
const attachments = new Set<Attachment>();
|
const attachments = new Set<Attachment>();
|
||||||
|
|
@ -154,7 +154,7 @@ export const AttachmentsTab: React.FunctionComponent<{
|
||||||
return <div className='attachment-item' key={attachmentKey(a, i)}>
|
return <div className='attachment-item' key={attachmentKey(a, i)}>
|
||||||
<ExpandableAttachment
|
<ExpandableAttachment
|
||||||
attachment={a}
|
attachment={a}
|
||||||
reveal={(!!revealedAttachment && isEqualAttachment(a, revealedAttachment)) ? revealedAttachment : undefined}
|
reveal={(!!revealedAttachment && isEqualAttachment(a, revealedAttachment[0])) ? revealedAttachment : undefined}
|
||||||
/>
|
/>
|
||||||
</div>;
|
</div>;
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ export const Workbench: React.FunctionComponent<{
|
||||||
}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, hideTimeline, status, annotations, inert, onOpenExternally, revealSource }) => {
|
}> = ({ model, showSourcesFirst, rootDir, fallbackLocation, isLive, hideTimeline, status, annotations, inert, onOpenExternally, revealSource }) => {
|
||||||
const [selectedCallId, setSelectedCallId] = React.useState<string | undefined>(undefined);
|
const [selectedCallId, setSelectedCallId] = React.useState<string | undefined>(undefined);
|
||||||
const [revealedError, setRevealedError] = React.useState<ErrorDescription | undefined>(undefined);
|
const [revealedError, setRevealedError] = React.useState<ErrorDescription | undefined>(undefined);
|
||||||
const [revealedAttachment, setRevealedAttachment] = React.useState<AfterActionTraceEventAttachment | undefined>(undefined);
|
const [revealedAttachment, setRevealedAttachment] = React.useState<[AfterActionTraceEventAttachment, number] | undefined>(undefined);
|
||||||
const [highlightedCallId, setHighlightedCallId] = React.useState<string | undefined>();
|
const [highlightedCallId, setHighlightedCallId] = React.useState<string | undefined>();
|
||||||
const [highlightedEntry, setHighlightedEntry] = React.useState<Entry | undefined>();
|
const [highlightedEntry, setHighlightedEntry] = React.useState<Entry | undefined>();
|
||||||
const [highlightedConsoleMessage, setHighlightedConsoleMessage] = React.useState<ConsoleEntry | undefined>();
|
const [highlightedConsoleMessage, setHighlightedConsoleMessage] = React.useState<ConsoleEntry | undefined>();
|
||||||
|
|
@ -148,7 +148,12 @@ export const Workbench: React.FunctionComponent<{
|
||||||
|
|
||||||
const revealAttachment = React.useCallback((attachment: AfterActionTraceEventAttachment) => {
|
const revealAttachment = React.useCallback((attachment: AfterActionTraceEventAttachment) => {
|
||||||
selectPropertiesTab('attachments');
|
selectPropertiesTab('attachments');
|
||||||
setRevealedAttachment({ ...attachment }); // copy to force re-render
|
setRevealedAttachment(currentValue => {
|
||||||
|
if (!currentValue)
|
||||||
|
return [attachment, 0];
|
||||||
|
const revealCounter = currentValue[1];
|
||||||
|
return [attachment, revealCounter + 1];
|
||||||
|
});
|
||||||
}, [selectPropertiesTab]);
|
}, [selectPropertiesTab]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue