Browse Source

Mutate PageTree data after publish/unpublish

Shun Miyazawa 2 years ago
parent
commit
2da62f1b0c

+ 2 - 0
apps/app/src/components/PageAlert/WipPageAlert.tsx

@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
 
 import { toastSuccess, toastError } from '~/client/util/toastr';
 import { useSWRMUTxCurrentPage, useSWRxCurrentPage } from '~/stores/page';
+import { mutatePageTree } from '~/stores/page-listing';
 
 import { publish } from '../../client/services/page-operation';
 
@@ -23,6 +24,7 @@ export const WipPageAlert = (): JSX.Element => {
     try {
       await publish(pageId);
       await mutateCurrentPage();
+      await mutatePageTree();
       toastSuccess(t('wip_page.success_publish_page'));
     }
     catch {

+ 2 - 0
apps/app/src/components/SavePageControls.tsx

@@ -16,6 +16,7 @@ import {
 } from '~/stores/context';
 import { useWaitingSaveProcessing } from '~/stores/editor';
 import { useSWRMUTxCurrentPage, useSWRxCurrentPage } from '~/stores/page';
+import { mutatePageTree } from '~/stores/page-listing';
 import { useSelectedGrant } from '~/stores/ui';
 import loggerFactory from '~/utils/logger';
 
@@ -72,6 +73,7 @@ export const SavePageControls = (props: SavePageControlsProps): JSX.Element | nu
     try {
       await unpublish(pageId);
       await mutateCurrentPage();
+      await mutatePageTree();
       toastSuccess(t('wip_page.success_save_as_wip'));
     }
     catch (err) {