Skip to content

Commit

Permalink
Invalidate query on mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
jtklein committed Mar 21, 2024
1 parent c627702 commit 4a6cd28
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/ObsDetails/DQAContainer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import { useRoute } from "@react-navigation/native";
import { useQueryClient } from "@tanstack/react-query";
import { faveObservation, unfaveObservation } from "api/observations";
import { deleteQualityMetric, fetchQualityMetrics, setQualityMetric } from "api/qualityMetrics";
import DataQualityAssessment from "components/ObsDetails/DataQualityAssessment";
Expand All @@ -19,11 +20,13 @@ import Observation from "realmModels/Observation";
import {
useAuthenticatedMutation,
useIsConnected,
useLocalObservation,
useRemoteObservation
useLocalObservation
} from "sharedHooks";
import useRemoteObservation,
{ fetchRemoteObservationKey } from "sharedHooks/useRemoteObservation.ts";

const DQAContainer = ( ): React.Node => {
const queryClient = useQueryClient( );
const isOnline = useIsConnected( );
const { params } = useRoute( );
const { observationUUID } = params;
Expand Down Expand Up @@ -99,7 +102,10 @@ const DQAContainer = ( ): React.Node => {
{
onSuccess: () => {
setNotLoading();
refetchRemoteObservation();
queryClient.invalidateQueries( [fetchRemoteObservationKey, observationUUID] );
if ( refetchRemoteObservation ) {
refetchRemoteObservation( );
}
},
onError: () => {
setHideErrorSheet( false );
Expand All @@ -112,7 +118,10 @@ const DQAContainer = ( ): React.Node => {
{
onSuccess: () => {
setNotLoading();
refetchRemoteObservation();
queryClient.invalidateQueries( [fetchRemoteObservationKey, observationUUID] );
if ( refetchRemoteObservation ) {
refetchRemoteObservation( );
}
},
onError: () => {
setHideErrorSheet( false );
Expand Down

0 comments on commit 4a6cd28

Please sign in to comment.