Skip to content

Commit

Permalink
fix infinite loop, improve breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelolo24 committed Apr 26, 2021
1 parent abf8cd9 commit f5fa7f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ const InvestigateInTimelineActionComponent = (alertIds: string[]) => {
};

export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) => {
const [caseTitle, setCaseTitle] = useState<string | null>(null);
const [spyState, setSpyState] = useState<{ caseTitle: string | undefined }>({
caseTitle: undefined,
});

const onCaseDataSuccess = useCallback(
(data: Case) => {
if (!caseTitle || caseTitle !== data.title) {
setCaseTitle(data.title);
if (spyState.caseTitle === undefined) {
setSpyState({ caseTitle: data.title });
}
},
[caseTitle]
[spyState.caseTitle]
);

const {
Expand Down Expand Up @@ -200,7 +202,6 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
})
);
}, [dispatch]);

return (
<>
{casesUi.getCaseView({
Expand Down Expand Up @@ -247,7 +248,7 @@ export const CaseView = React.memo(({ caseId, subCaseId, userCanCrud }: Props) =
useFetchAlertData,
userCanCrud,
})}
{caseTitle && <SpyRoute state={{ caseTitle }} pageName={SecurityPageName.case} />}
<SpyRoute state={spyState} pageName={SecurityPageName.case} />
</>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,19 @@ const AddToCaseButtonComponent: React.FC<Props> = ({ timelineId }) => {

const handleNewCaseClick = useCallback(() => {
handlePopoverClose();

dispatch(showTimeline({ id: TimelineId.active, show: false }));

navigateToApp(`${APP_ID}:${SecurityPageName.case}`, {
path: getCreateCaseUrl(),
}).then(() =>
}).then(() => {
dispatch(
setInsertTimeline({
graphEventId,
timelineId,
timelineSavedObjectId: savedObjectId,
timelineTitle: timelineTitle.length > 0 ? timelineTitle : i18n.UNTITLED_TIMELINE,
})
)
);
);
dispatch(showTimeline({ id: TimelineId.active, show: false }));
});
}, [
dispatch,
graphEventId,
Expand Down

0 comments on commit f5fa7f1

Please sign in to comment.