Skip to content

Commit

Permalink
TEN-538: Abort call to Oversikt from Searchpage, when navigating away…
Browse files Browse the repository at this point in the history
… when deleting
  • Loading branch information
rittikdey committed Dec 20, 2023
1 parent 41f36fb commit e6f55c5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pages/SvarSed/SEDSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { useAppDispatch, useAppSelector } from 'store'
import styled from 'styled-components'
import {sign} from "crypto";

export const FlexRadioGroup = styled(RadioGroup)`
.navds-radio-buttons {
Expand Down Expand Up @@ -77,11 +78,20 @@ const SEDSearch = (): JSX.Element => {
const namespace = 'sedsearch'

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

if (_query && !_.isNil(deletedSak)) {
// if we are deleting a sak, and query was saksnummer, then we are deleting the same sak, nothing to query
// but if we are querying fnr/dnr, we have to query again so we can have a sak list without the deleted sak
if (_queryType !== 'saksnummer') {
dispatch(querySaks(_query!, 'new'))
dispatch(querySaks(_query!, 'new', false, signal))
}
}

return () => {
if(controller){
controller.abort();
}
}
}, [deletedSak])
Expand Down

0 comments on commit e6f55c5

Please sign in to comment.