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 React, { ErrorInfo } from 'react';
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
import { useQuery } from 'react-query';
|
import { useQuery, useQueryClient } from 'react-query';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import Client, { ChangeHistory } from '../../../../classes/client';
|
import Client, { ChangeHistory } from '../../../../classes/client';
|
||||||
import { activeInstance } from '../../../../redux/clientSlice';
|
import { activeInstance } from '../../../../redux/clientSlice';
|
||||||
@ -22,16 +22,20 @@ const HistoryDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElemen
|
|||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const client: Client = useSelector(activeInstance);
|
const client: Client = useSelector(activeInstance);
|
||||||
const { data } = useQuery<unknown, ErrorInfo, ChangeHistory[]>('history', () => {
|
const { data } = useQuery<unknown, ErrorInfo, ChangeHistory[]>(`history-${mapId}`, () => {
|
||||||
return client.fetchHistory(mapId);
|
return client.fetchHistory(mapId);
|
||||||
});
|
});
|
||||||
const changeHistory: ChangeHistory[] = data ? data : [];
|
const changeHistory: ChangeHistory[] = data ? data : [];
|
||||||
|
|
||||||
const handleOnClose = (): void => {
|
const handleOnClose = (): void => {
|
||||||
onClose();
|
onClose();
|
||||||
|
|
||||||
|
// Invalidate cache ...
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
queryClient.invalidateQueries(`history-${mapId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnClick = (event, vid): void => {
|
const handleOnClick = (event, vid: number): void => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
client.revertHistory(mapId, vid).then(() => {
|
client.revertHistory(mapId, vid).then(() => {
|
||||||
handleOnClose();
|
handleOnClose();
|
||||||
|
@ -84,6 +84,10 @@ const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement
|
|||||||
|
|
||||||
const handleOnClose = (): void => {
|
const handleOnClose = (): void => {
|
||||||
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 => {
|
||||||
@ -109,8 +113,7 @@ const ShareDialog = ({ mapId, onClose }: SimpleDialogProps): React.ReactElement
|
|||||||
deleteMutation.mutate(email);
|
deleteMutation.mutate(email);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { isLoading, data: permissions = [] } = useQuery<unknown, ErrorInfo, Permission[]>(
|
const { isLoading, data: permissions = [] } = useQuery<unknown, ErrorInfo, Permission[]>(`perm-${mapId}`,
|
||||||
`perm-${mapId}`,
|
|
||||||
() => {
|
() => {
|
||||||
return client.fetchMapPermissions(mapId);
|
return client.fetchMapPermissions(mapId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user