* Task update sync issue #1203 * removed unwanted state
This commit is contained in:
committed by
GitHub
parent
a24e1e4dc9
commit
4f524bd2a7
@ -1,11 +1,13 @@
|
|||||||
import { useCallback } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { useApolloClient } from '@apollo/client';
|
import { useApolloClient } from '@apollo/client';
|
||||||
|
import { getOperationName } from '@apollo/client/utilities';
|
||||||
|
|
||||||
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
import { Activity, useUpdateActivityMutation } from '~/generated/graphql';
|
||||||
|
|
||||||
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
import { ACTIVITY_UPDATE_FRAGMENT } from '../graphql/fragments/activityUpdateFragment';
|
||||||
|
import { GET_ACTIVITIES } from '../graphql/queries/getActivities';
|
||||||
|
|
||||||
type Task = Pick<Activity, 'id'>;
|
type Task = Pick<Activity, 'id' | 'completedAt'>;
|
||||||
|
|
||||||
export function useCompleteTask(task: Task) {
|
export function useCompleteTask(task: Task) {
|
||||||
const [updateActivityMutation] = useUpdateActivityMutation();
|
const [updateActivityMutation] = useUpdateActivityMutation();
|
||||||
@ -33,6 +35,7 @@ export function useCompleteTask(task: Task) {
|
|||||||
completedAt,
|
completedAt,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
refetchQueries: [getOperationName(GET_ACTIVITIES) ?? ''],
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[cachedTask, task.id, updateActivityMutation],
|
[cachedTask, task.id, updateActivityMutation],
|
||||||
|
|||||||
Reference in New Issue
Block a user