Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/issues-112-mo…
Browse files Browse the repository at this point in the history
…bile-post-form
  • Loading branch information
takecchi committed Dec 20, 2023
2 parents 4da3502 + 7c21ccf commit 8e5fad5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/_components/post/PostDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,6 +52,7 @@ export default function PostDialog({ fullScreen, open, close }: Props) {
useState(false);
const [getErrorMessage, setErrorMesssage] = useState('');
const [getSucceedMessage, setSucceedMessage] = useState('');
const { mutateLatest } = useHomeTimelineImmutable();

// NOTE: 閉じきる前に微妙に空になるのが見えるので
// それが嫌ならsetTimeout(unmount時にcb呼ぶ方法あるならそっち)で包む
Expand Down Expand Up @@ -89,6 +91,7 @@ export default function PostDialog({ fullScreen, open, close }: Props) {
onSucceed={() => {
setSucceedMessage('送信しました。');
clearContent();
void mutateLatest();
close();
}}
onError={(e) => {
Expand Down
12 changes: 12 additions & 0 deletions src/swr/client/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserPost, Error, TimelineKey>(swrKey, fetcher, {
enableQueue: true,
});
};

0 comments on commit 8e5fad5

Please sign in to comment.