mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-11 01:43:23 +01:00
Add cache clean on closed.
This commit is contained in:
parent
31dc83d30b
commit
c31fd338ec
@ -1,6 +1,6 @@
|
||||
import React, { ErrorInfo } from 'react';
|
||||
import { FormattedMessage, useIntl } from 'react-intl';
|
||||
import { useQuery } from 'react-query';
|
||||
import { useQuery, useQueryClient } from 'react-query';
|
||||
import { useSelector } from 'react-redux';
|
||||
import Client, { ChangeHistory } from '../../../../classes/client';
|
||||
import { activeInstance } from '../../../../redux/clientSlice';
|
||||
@ -22,16 +22,20 @@ const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
|
||||
const intl = useIntl();
|
||||
|
||||
const client: Client = useSelector(activeInstance);
|
||||
const { data } = useQuery<unknown, ErrorInfo, ChangeHistory[]>('history', () => {
|
||||
const { data } = useQuery<unknown, ErrorInfo, ChangeHistory[]>(`history-${mapId}`, () => {
|
||||
return client.fetchHistory(mapId);
|
||||
});
|
||||
const changeHistory: ChangeHistory[] = data ? data : [];
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
onClose();
|
||||
|
||||
// Invalidate cache ...
|
||||
const queryClient = useQueryClient();
|
||||
queryClient.invalidateQueries(`history-${mapId}`);
|
||||
};
|
||||
|
||||
const handleOnClick = (event, vid): void => {
|
||||
const handleOnClick = (event, vid: number): void => {
|
||||
event.preventDefault();
|
||||
client.revertHistory(mapId, vid).then(() => {
|
||||
handleOnClose();
|
||||
|
@ -84,6 +84,10 @@ const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement
|
||||
|
||||
const handleOnClose = (): void => {
|
||||
onClose();
|
||||
|
||||
// Invalidate cache ...
|
||||
const queryClient = useQueryClient();
|
||||
queryClient.invalidateQueries(`perm-${mapId}`);
|
||||
};
|
||||
|
||||
const handleOnChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
||||
@ -109,8 +113,7 @@ const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement
|
||||
deleteMutation.mutate(email);
|
||||
};
|
||||
|
||||
const { isLoading, data: permissions = [] } = useQuery<unknown, ErrorInfo, Permission[]>(
|
||||
`perm-${mapId}`,
|
||||
const { isLoading, data: permissions = [] } = useQuery<unknown, ErrorInfo, Permission[]>(`perm-${mapId}`,
|
||||
() => {
|
||||
return client.fetchMapPermissions(mapId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user