Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#128 指摘事項修正 #135

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const StyledButton = styled(IconButton)`
`;

export default function MobileOpenPostDialogButton() {
const [getOpenDialog, setOpenDialog] = useState(false);
const [openDialog, setOpenDialog] = useState(false);

const renderablePaths = ['/home', '/search', '/notifications'];
const renderable = renderablePaths.includes(usePathname() as string);
Expand All @@ -59,7 +59,7 @@ export default function MobileOpenPostDialogButton() {

<PostDialog
fullScreen
open={getOpenDialog}
open={openDialog}
close={() => setOpenDialog(false)}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const SideMenuAccountButton = ({
userName,
profileAvatarImageUrl,
}: Props) => {
const [getShowAccountMenu, setShowAccountMenu] = useState(false);
const [showAccountMenu, setShowAccountMenu] = useState(false);
const accountMenuRef = useRef(null);

return (
Expand All @@ -106,7 +106,7 @@ const SideMenuAccountButton = ({
</HFlex>

<Menu
open={getShowAccountMenu}
open={showAccountMenu}
onClose={() => setShowAccountMenu(false)}
anchorEl={accountMenuRef.current}
anchorOrigin={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Label = styled(`span`)`
}
`;
const SideMenuPostButton = () => {
const [getShowPostDialog, setShowPostDialog] = useState(false);
const [showPostDialog, setShowPostDialog] = useState(false);

return (
<>
Expand All @@ -47,7 +47,7 @@ const SideMenuPostButton = () => {
</Wrapper>

<PostDialog
open={getShowPostDialog}
open={showPostDialog}
close={() => setShowPostDialog(false)}
/>
</>
Expand Down
41 changes: 18 additions & 23 deletions src/app/_components/post/PostDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ interface Props {
}

export default function PostDialog({ fullScreen, open, close }: Props) {
const [getContent, setContent] = useState('');
const [getShowConfirmCloseDialog, setShowConfirmCloseDialog] =
useState(false);
const [getErrorMessage, setErrorMesssage] = useState('');
const [getSucceedMessage, setSucceedMessage] = useState('');
const [content, setContent] = useState('');
const [showConfirmCloseDialog, setShowConfirmCloseDialog] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
const [successMessage, setSuccessMessage] = useState('');
const { mutateLatest } = useHomeTimelineImmutable();

// NOTE: 閉じきる前に微妙に空になるのが見えるので
Expand All @@ -64,55 +63,51 @@ export default function PostDialog({ fullScreen, open, close }: Props) {
<Dialog
fullScreen={fullScreen}
open={open}
onClose={() => (getContent.length ? confirmAndClose() : close())}
onClose={() => (content.length ? confirmAndClose() : close())}
>
<StyledDialogTitle>
<HFlex>
<IconButton
onClick={() => (getContent.length ? confirmAndClose() : close())}
onClick={() => (content.length ? confirmAndClose() : close())}
>
<Close />
</IconButton>
</HFlex>
</StyledDialogTitle>

<StyledDialogContent>
<PostForm
getContent={getContent}
setContent={setContent}
focusEditor
/>
<PostForm getContent={content} setContent={setContent} focusEditor />
</StyledDialogContent>

<StyledDialogActions>
<SendPostButton
disabled={!getContent.length}
sendData={{ plainText: getContent }}
disabled={!content.length}
sendData={{ plainText: content }}
onSucceed={() => {
setSucceedMessage('送信しました。');
setSuccessMessage('送信しました。');
clearContent();
void mutateLatest();
close();
}}
onError={(e) => {
// TODO: リリース前に消す?
console.error(e);
setErrorMesssage('送信に失敗しました。');
setErrorMessage('送信に失敗しました。');
}}
/>
</StyledDialogActions>

<Snackbar
open={!!getErrorMessage.length}
onClose={() => setErrorMesssage('')}
open={!!errorMessage.length}
onClose={() => setErrorMessage('')}
autoHideDuration={2_000}
>
<Alert severity="error">{getErrorMessage}</Alert>
<Alert severity="error">{errorMessage}</Alert>
</Snackbar>
</Dialog>

<ConfirmClosePostDialogDialog
open={getShowConfirmCloseDialog}
open={showConfirmCloseDialog}
close={() => setShowConfirmCloseDialog(false)}
actions={[
{
Expand All @@ -127,11 +122,11 @@ export default function PostDialog({ fullScreen, open, close }: Props) {
/>

<Snackbar
open={!!getSucceedMessage.length}
onClose={() => setSucceedMessage('')}
open={!!successMessage.length}
onClose={() => setSuccessMessage('')}
autoHideDuration={2_000}
>
<Alert severity="success">{getSucceedMessage}</Alert>
<Alert severity="success">{successMessage}</Alert>
</Snackbar>
</Box>
);
Expand Down
Loading