|
@@ -6,6 +6,7 @@ import { format } from 'date-fns/format';
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
|
|
import { useCreatePageAndTransit } from '~/client/services/create-page';
|
|
import { useCreatePageAndTransit } from '~/client/services/create-page';
|
|
|
|
|
+import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
import { useCurrentUser } from '~/stores/context';
|
|
import { useCurrentUser } from '~/stores/context';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -25,21 +26,23 @@ export const useCreateTodaysMemo: UseCreateTodaysMemo = () => {
|
|
|
|
|
|
|
|
const parentDirName = t('create_page_dropdown.todays.memo');
|
|
const parentDirName = t('create_page_dropdown.todays.memo');
|
|
|
const now = format(new Date(), 'yyyy/MM/dd');
|
|
const now = format(new Date(), 'yyyy/MM/dd');
|
|
|
- const parentPath = `${userHomepagePath(currentUser)}/${parentDirName}`;
|
|
|
|
|
const todaysPath = isCreatable
|
|
const todaysPath = isCreatable
|
|
|
- ? `${parentPath}/${now}`
|
|
|
|
|
|
|
+ ? `${userHomepagePath(currentUser)}/${parentDirName}/${now}`
|
|
|
: null;
|
|
: null;
|
|
|
|
|
|
|
|
const createTodaysMemo = useCallback(async() => {
|
|
const createTodaysMemo = useCallback(async() => {
|
|
|
if (!isCreatable || todaysPath == null) return;
|
|
if (!isCreatable || todaysPath == null) return;
|
|
|
|
|
|
|
|
|
|
+ const res = await apiv3Get('/page/non-empty-closest-ancestor', { path: todaysPath });
|
|
|
|
|
+ const parentPath = res.data.nonEmptyClosestAncestor?.path;
|
|
|
|
|
+
|
|
|
return createAndTransit(
|
|
return createAndTransit(
|
|
|
{
|
|
{
|
|
|
path: todaysPath, parentPath, wip: true, origin: Origin.View,
|
|
path: todaysPath, parentPath, wip: true, origin: Origin.View,
|
|
|
},
|
|
},
|
|
|
{ shouldCheckPageExists: true },
|
|
{ shouldCheckPageExists: true },
|
|
|
);
|
|
);
|
|
|
- }, [createAndTransit, isCreatable, todaysPath, parentPath]);
|
|
|
|
|
|
|
+ }, [createAndTransit, isCreatable, todaysPath]);
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
isCreating,
|
|
isCreating,
|