|
@@ -16,7 +16,7 @@ import { throttle, debounce } from 'throttle-debounce';
|
|
|
|
|
|
|
|
import { useUpdateStateAfterSave, useSaveOrUpdate } from '~/client/services/page-operation';
|
|
import { useUpdateStateAfterSave, useSaveOrUpdate } from '~/client/services/page-operation';
|
|
|
import { apiGet, apiPostForm } from '~/client/util/apiv1-client';
|
|
import { apiGet, apiPostForm } from '~/client/util/apiv1-client';
|
|
|
-import { toastError, toastSuccess, toastWarning } from '~/client/util/toastr';
|
|
|
|
|
|
|
+import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
import { IEditorMethods } from '~/interfaces/editor-methods';
|
|
import { IEditorMethods } from '~/interfaces/editor-methods';
|
|
|
import { OptionsToSave } from '~/interfaces/page-operation';
|
|
import { OptionsToSave } from '~/interfaces/page-operation';
|
|
|
import { SocketEventName } from '~/interfaces/websocket';
|
|
import { SocketEventName } from '~/interfaces/websocket';
|
|
@@ -35,6 +35,12 @@ import {
|
|
|
useCurrentPagePath, useSWRMUTxCurrentPage, useSWRxCurrentPage, useSWRxTagsInfo,
|
|
useCurrentPagePath, useSWRMUTxCurrentPage, useSWRxCurrentPage, useSWRxTagsInfo,
|
|
|
} from '~/stores/page';
|
|
} from '~/stores/page';
|
|
|
import { mutatePageTree } from '~/stores/page-listing';
|
|
import { mutatePageTree } from '~/stores/page-listing';
|
|
|
|
|
+import {
|
|
|
|
|
+ useRemoteRevisionId,
|
|
|
|
|
+ useRemoteRevisionBody,
|
|
|
|
|
+ useRemoteRevisionLastUpdatedAt,
|
|
|
|
|
+ useRemoteRevisionLastUpdateUser,
|
|
|
|
|
+} from '~/stores/remote-latest-page';
|
|
|
import { usePreviewOptions } from '~/stores/renderer';
|
|
import { usePreviewOptions } from '~/stores/renderer';
|
|
|
import {
|
|
import {
|
|
|
EditorMode,
|
|
EditorMode,
|
|
@@ -92,6 +98,10 @@ const PageEditor = React.memo((): JSX.Element => {
|
|
|
const { data: isUploadableFile } = useIsUploadableFile();
|
|
const { data: isUploadableFile } = useIsUploadableFile();
|
|
|
const { data: isUploadableImage } = useIsUploadableImage();
|
|
const { data: isUploadableImage } = useIsUploadableImage();
|
|
|
const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
|
|
const { data: conflictDiffModalStatus, close: closeConflictDiffModal } = useConflictDiffModal();
|
|
|
|
|
+ const { mutate: mutateRemotePageId } = useRemoteRevisionId();
|
|
|
|
|
+ const { mutate: mutateRemoteRevisionId } = useRemoteRevisionBody();
|
|
|
|
|
+ const { mutate: mutateRemoteRevisionLastUpdatedAt } = useRemoteRevisionLastUpdatedAt();
|
|
|
|
|
+ const { mutate: mutateRemoteRevisionLastUpdateUser } = useRemoteRevisionLastUpdateUser();
|
|
|
|
|
|
|
|
const { data: rendererOptions, mutate: mutateRendererOptions } = usePreviewOptions();
|
|
const { data: rendererOptions, mutate: mutateRendererOptions } = usePreviewOptions();
|
|
|
const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
@@ -218,18 +228,18 @@ const PageEditor = React.memo((): JSX.Element => {
|
|
|
logger.error('failed to save', error);
|
|
logger.error('failed to save', error);
|
|
|
toastError(error);
|
|
toastError(error);
|
|
|
if (error.code === 'conflict') {
|
|
if (error.code === 'conflict') {
|
|
|
- toastWarning('(TBD) resolve conflict');
|
|
|
|
|
- // pageContainer.setState({
|
|
|
|
|
- // remoteRevisionId: error.data.revisionId,
|
|
|
|
|
- // remoteRevisionBody: error.data.revisionBody,
|
|
|
|
|
- // remoteRevisionUpdateAt: error.data.createdAt,
|
|
|
|
|
- // lastUpdateUser: error.data.user,
|
|
|
|
|
- // });
|
|
|
|
|
|
|
+ mutateRemotePageId(error.data.revisionId);
|
|
|
|
|
+ mutateRemoteRevisionId(error.data.revisionBody);
|
|
|
|
|
+ mutateRemoteRevisionLastUpdatedAt(error.data.createdAt);
|
|
|
|
|
+ mutateRemoteRevisionLastUpdateUser(error.data.user);
|
|
|
}
|
|
}
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- }, [currentPathname, optionsToSave, grantData, isSlackEnabled, saveOrUpdate, pageId, currentPagePath, currentRevisionId]);
|
|
|
|
|
|
|
+ }, [
|
|
|
|
|
+ currentPathname, optionsToSave, grantData, isSlackEnabled, saveOrUpdate, pageId,
|
|
|
|
|
+ currentPagePath, currentRevisionId, mutateRemotePageId, mutateRemoteRevisionId, mutateRemoteRevisionLastUpdatedAt, mutateRemoteRevisionLastUpdateUser,
|
|
|
|
|
+ ]);
|
|
|
|
|
|
|
|
const saveAndReturnToViewHandler = useCallback(async(opts: {slackChannels: string, overwriteScopesOfDescendants?: boolean}) => {
|
|
const saveAndReturnToViewHandler = useCallback(async(opts: {slackChannels: string, overwriteScopesOfDescendants?: boolean}) => {
|
|
|
if (editorMode !== EditorMode.Editor) {
|
|
if (editorMode !== EditorMode.Editor) {
|