Fix share dialog cache issue

This commit is contained in:
Paulo Gustavo Veiga 2022-04-07 21:18:00 -03:00
parent 89ce9f2a60
commit 860e46d3ec

View File

@ -34,6 +34,7 @@ type ShareModel = {
const defaultModel: ShareModel = { emails: '', role: 'editor', message: '' }; const defaultModel: ShareModel = { emails: '', role: 'editor', message: '' };
const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => { const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement => {
const intl = useIntl(); const intl = useIntl();
const queryClient = useQueryClient();
const client: Client = useSelector(activeInstance); const client: Client = useSelector(activeInstance);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const classes = useStyles(); const classes = useStyles();
@ -83,11 +84,10 @@ const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement
); );
const handleOnClose = (): void => { const handleOnClose = (): void => {
// Invalidate cache ...
queryClient.invalidateQueries(`perm-${mapId}`);
onClose(); onClose();
// Invalidate cache ...
const queryClient = useQueryClient();
queryClient.invalidateQueries(`perm-${mapId}`);
}; };
const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>): void => { const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>): void => {