Skip to content

Commit

Permalink
TEN-538: Abort call to Oversikt from Frontpage, when navigating away …
Browse files Browse the repository at this point in the history
…before finished
  • Loading branch information
rittikdey committed Dec 20, 2023
1 parent edb7d0a commit 9ab17fc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pages/Forside/Forside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ const Forside: React.FC = (): JSX.Element => {
}
}, [])

useEffect(() => {
let controller = new AbortController();
const signal = controller.signal;

if(_query){
dispatch(querySaks(_query, 'new', false, signal))
}

return () => {
if(controller){
controller.abort();
}
}
}, [_query])

useEffect(() => {
if (saks?.length === 1 && _queryType === 'saksnummer') {
dispatch(setCurrentSak(saks[0]))
Expand Down Expand Up @@ -137,7 +152,6 @@ const Forside: React.FC = (): JSX.Element => {
}}
onQuerySubmit={(q: string) => {
_setQuery(q)
dispatch(querySaks(q, 'new'))
}}
querying={queryingSaks}
error={!!alertMessage && alertType && [types.SVARSED_SAKS_FAILURE].indexOf(alertType) >= 0 ? alertMessage : undefined}
Expand Down

0 comments on commit 9ab17fc

Please sign in to comment.