diff --git a/src/app/_components/post/PostDialog.tsx b/src/app/_components/post/PostDialog.tsx index 105802fd..b526b8b3 100644 --- a/src/app/_components/post/PostDialog.tsx +++ b/src/app/_components/post/PostDialog.tsx @@ -16,6 +16,7 @@ import { styled, } from '@mui/material'; import { useState } from 'react'; +import { useHomeTimelineImmutable } from '@/swr/client/timeline'; const Flex = styled('div')` display: flex; @@ -50,6 +51,7 @@ export default function PostDialog({ open, close }: Props) { useState(false); const [getErrorMessage, setErrorMesssage] = useState(''); const [getSucceedMessage, setSucceedMessage] = useState(''); + const { mutateLatest } = useHomeTimelineImmutable(); // NOTE: 閉じきる前に微妙に空になるのが見えるので // それが嫌ならsetTimeout(unmount時にcb呼ぶ方法あるならそっち)で包む @@ -87,6 +89,7 @@ export default function PostDialog({ open, close }: Props) { onSucceed={() => { setSucceedMessage('送信しました。'); clearContent(); + void mutateLatest(); close(); }} onError={(e) => { diff --git a/src/swr/client/timeline.ts b/src/swr/client/timeline.ts index ac168f8e..c1922d52 100644 --- a/src/swr/client/timeline.ts +++ b/src/swr/client/timeline.ts @@ -52,3 +52,15 @@ export const useHomeTimeline = () => { enableQueue: true, }); }; + +/** + * メインとなるタイムライン + * 自動更新OFF + */ +export const useHomeTimelineImmutable = () => { + const { data: authId } = useAuth(); + const swrKey = authId ? getKey('useHomeTimeline', authId) : () => null; + return useSWRTimeline(swrKey, fetcher, { + enableQueue: true, + }); +};