From 71f8fc86a4216cf55b0aa425fe0b279499a68d6a Mon Sep 17 00:00:00 2001 From: Paul Makles Date: Fri, 10 Jun 2022 17:00:37 +0100 Subject: [PATCH] chore: fix build errors --- src/context/intermediate/modals/Prompt.tsx | 20 +++++++++++++------ .../intermediate/popovers/CreateBot.tsx | 6 ++++-- .../intermediate/popovers/ModifyAccount.tsx | 5 ++++- .../intermediate/popovers/UserPicker.tsx | 2 +- src/pages/settings/Settings.tsx | 2 +- src/types/revolt-api.d.ts | 2 +- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/context/intermediate/modals/Prompt.tsx b/src/context/intermediate/modals/Prompt.tsx index b3d15395..31fc2d59 100644 --- a/src/context/intermediate/modals/Prompt.tsx +++ b/src/context/intermediate/modals/Prompt.tsx @@ -168,10 +168,11 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { break; } - onClose(); + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, @@ -210,10 +211,11 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { try { props.target.delete(); - onClose(); + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, @@ -316,10 +318,11 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { }) ?.kick(); - onClose(); + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, @@ -366,10 +369,12 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { await props.target.banUser(props.user._id, { reason, }); - onClose(); + + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, @@ -438,10 +443,11 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { ); } - onClose(); + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, @@ -512,11 +518,13 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { }, ], }); - onClose(); + setProcessing(false); + return true; } catch (err) { setError(takeError(err)); setProcessing(false); + return false; } }, }, diff --git a/src/context/intermediate/popovers/CreateBot.tsx b/src/context/intermediate/popovers/CreateBot.tsx index 515063e7..80a8032c 100644 --- a/src/context/intermediate/popovers/CreateBot.tsx +++ b/src/context/intermediate/popovers/CreateBot.tsx @@ -29,7 +29,6 @@ export function CreateBotModal({ onClose, onCreate }: Props) { try { const { bot } = await client.bots.create({ name }); onCreate(bot); - onClose(); } catch (err) { setError(takeError(err)); } @@ -43,7 +42,10 @@ export function CreateBotModal({ onClose, onCreate }: Props) { { confirmation: true, palette: "accent", - onClick: handleSubmit(onSubmit), + onClick: async () => { + await handleSubmit(onSubmit); + return true; + }, children: , }, { diff --git a/src/context/intermediate/popovers/ModifyAccount.tsx b/src/context/intermediate/popovers/ModifyAccount.tsx index e1da7573..dadb6320 100644 --- a/src/context/intermediate/popovers/ModifyAccount.tsx +++ b/src/context/intermediate/popovers/ModifyAccount.tsx @@ -74,7 +74,10 @@ export function ModifyAccountModal({ onClose, field }: Props) { actions={[ { confirmation: true, - onClick: handleSubmit(onSubmit), + onClick: async () => { + await handleSubmit(onSubmit); + return true; + }, children: field === "email" ? ( diff --git a/src/context/intermediate/popovers/UserPicker.tsx b/src/context/intermediate/popovers/UserPicker.tsx index 35af13e2..d1aeecf8 100644 --- a/src/context/intermediate/popovers/UserPicker.tsx +++ b/src/context/intermediate/popovers/UserPicker.tsx @@ -26,7 +26,7 @@ export function UserPicker(props: Props) { actions={[ { children: , - onClick: () => props.callback(selected).then(props.onClose), + onClick: () => props.callback(selected).then(() => true), }, ]}>
diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx index 28743654..fd30d6b8 100644 --- a/src/pages/settings/Settings.tsx +++ b/src/pages/settings/Settings.tsx @@ -278,7 +278,7 @@ export default observer(() => { logout()} className={styles.logOut} compact> diff --git a/src/types/revolt-api.d.ts b/src/types/revolt-api.d.ts index 664e6ab1..ae1bb349 100644 --- a/src/types/revolt-api.d.ts +++ b/src/types/revolt-api.d.ts @@ -1,6 +1,6 @@ // TODO: re-export from revolt-api in some way declare type Session = { - _id: string; + _id?: string; token: string; name: string; user_id: string;