From fd4e2733ba5d21a3624fe4f07562d4ffff05c603 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Thu, 21 Sep 2023 14:51:13 -0400 Subject: [PATCH] Frontend: [hour/s old bug] Ensure type null option for lastEditedQueryId (#14055) --- frontend/context/policy.tsx | 15 +++++++++------ frontend/context/query.tsx | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/context/policy.tsx b/frontend/context/policy.tsx index af47f2fe77..7694b0e130 100644 --- a/frontend/context/policy.tsx +++ b/frontend/context/policy.tsx @@ -165,12 +165,15 @@ const PolicyProvider = ({ children }: Props): JSX.Element => { dispatch({ type: ACTIONS.SET_POLICY_TEAM_ID, id }); }, []); - const setLastEditedQueryId = useCallback((lastEditedQueryId: number) => { - dispatch({ - type: ACTIONS.SET_LAST_EDITED_QUERY_INFO, - lastEditedQueryId, - }); - }, []); + const setLastEditedQueryId = useCallback( + (lastEditedQueryId: number | null) => { + dispatch({ + type: ACTIONS.SET_LAST_EDITED_QUERY_INFO, + lastEditedQueryId, + }); + }, + [] + ); const setLastEditedQueryName = useCallback((lastEditedQueryName: string) => { dispatch({ diff --git a/frontend/context/query.tsx b/frontend/context/query.tsx index f5778a9973..992e152cad 100644 --- a/frontend/context/query.tsx +++ b/frontend/context/query.tsx @@ -22,7 +22,7 @@ type InitialStateType = { lastEditedQueryPlatforms: SelectedPlatformString; lastEditedQueryMinOsqueryVersion: string; lastEditedQueryLoggingType: QueryLoggingOption; - setLastEditedQueryId: (value: number) => void; + setLastEditedQueryId: (value: number | null) => void; setLastEditedQueryName: (value: string) => void; setLastEditedQueryDescription: (value: string) => void; setLastEditedQueryBody: (value: string) => void; @@ -135,7 +135,7 @@ const QueryProvider = ({ children }: Props) => { lastEditedQueryPlatforms: state.lastEditedQueryPlatforms, lastEditedQueryMinOsqueryVersion: state.lastEditedQueryMinOsqueryVersion, lastEditedQueryLoggingType: state.lastEditedQueryLoggingType, - setLastEditedQueryId: (lastEditedQueryId: number) => { + setLastEditedQueryId: (lastEditedQueryId: number | null) => { dispatch({ type: actions.SET_LAST_EDITED_QUERY_INFO, lastEditedQueryId,