|
|
@@ -7,7 +7,7 @@ type DrawioModalSaveHandler = () => void;
|
|
|
|
|
|
type DrawioModalStatus = {
|
|
|
isOpened: boolean,
|
|
|
- editorKey: string,
|
|
|
+ editorKey: string | undefined,
|
|
|
onSave?: DrawioModalSaveHandler,
|
|
|
}
|
|
|
|
|
|
@@ -22,18 +22,18 @@ type DrawioModalStatusUtils = {
|
|
|
export const useDrawioModalForEditor = (status?: DrawioModalStatus): SWRResponse<DrawioModalStatus, Error> & DrawioModalStatusUtils => {
|
|
|
const initialData: DrawioModalStatus = {
|
|
|
isOpened: false,
|
|
|
- editorKey: '',
|
|
|
+ editorKey: undefined,
|
|
|
};
|
|
|
const swrResponse = useSWRStatic<DrawioModalStatus, Error>('drawioModalStatus', status, { fallbackData: initialData });
|
|
|
|
|
|
const { mutate } = swrResponse;
|
|
|
|
|
|
- const open = useCallback((editorKey: string, onSave?: DrawioModalSaveHandler): void => {
|
|
|
+ const open = useCallback((editorKey: string | undefined, onSave?: DrawioModalSaveHandler): void => {
|
|
|
mutate({ isOpened: true, editorKey, onSave });
|
|
|
}, [mutate]);
|
|
|
|
|
|
const close = useCallback((): void => {
|
|
|
- mutate({ isOpened: false, editorKey: '', onSave: undefined });
|
|
|
+ mutate({ isOpened: false, editorKey: undefined, onSave: undefined });
|
|
|
}, [mutate]);
|
|
|
|
|
|
return {
|