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