fixing flow to make sure that failures don't clear form
This commit is contained in:
@@ -21,7 +21,7 @@ interface IConversationContext {
|
||||
selectedConversation?: MasterConversation;
|
||||
selectConversation?: (conversationId: string, temporaryOverrideSort?: boolean) => Promise<void>;
|
||||
|
||||
handleStartConversation?: (otherUsers: User[], conversationName?: string) => Promise<void>;
|
||||
handleStartConversation?: (otherUsers: User[], conversationName?: string) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const ConversationContext = React.createContext<IConversationContext>({
|
||||
@@ -139,10 +139,13 @@ export function ConversationProvider({ children }: { children: React.ReactNode }
|
||||
selectConversation(createdConversationResult.data.conversationId.toString(), true);
|
||||
|
||||
toast.success('started conversation');
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error(error.message);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
[selectConversation],
|
||||
);
|
||||
|
||||
@@ -97,11 +97,13 @@ export default function NewConversationDialog() {
|
||||
|
||||
setIsSubmitting(true);
|
||||
|
||||
await handleStartConversation(selectedUsers, conversationName);
|
||||
const succeeded = await handleStartConversation(selectedUsers, conversationName);
|
||||
|
||||
// clear form for next time
|
||||
setSelectedUsers([]);
|
||||
setConversationName('');
|
||||
if (succeeded) {
|
||||
setSelectedUsers([]);
|
||||
setConversationName('');
|
||||
}
|
||||
|
||||
setIsSubmitting(false);
|
||||
}, [
|
||||
|
||||
@@ -35,7 +35,9 @@ export default function Terminal() {
|
||||
>
|
||||
<Navbar />
|
||||
|
||||
<ConversationList />
|
||||
<Box sx={{ p: 2 }}>
|
||||
<ConversationList />
|
||||
</Box>
|
||||
</Grid>
|
||||
|
||||
<Grid item xs={8} sx={{ bgcolor: 'white' }}>
|
||||
|
||||
Reference in New Issue
Block a user