mirror of
https://github.com/suitenumerique/messages.git
synced 2026-09-26 11:44:55 +02:00
🐛(frontend) draftBody can be null
There was an error in the openapi schema and we are not aware that message.draftBody could be null so when it was the case, the frontend throws an error when rendering the `MessageForm` component.
This commit is contained in:
committed by
Jean-Baptiste PENRATH
parent
f68925b8bd
commit
d0b2a66f08
@@ -4696,6 +4696,7 @@
|
||||
},
|
||||
"draftBody": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"readOnly": true
|
||||
},
|
||||
"attachments": {
|
||||
|
||||
@@ -532,7 +532,7 @@ class MessageSerializer(serializers.ModelSerializer):
|
||||
"""Return the list of HTML body parts (JMAP style)."""
|
||||
return instance.get_parsed_field("htmlBody") or []
|
||||
|
||||
@extend_schema_field(serializers.CharField())
|
||||
@extend_schema_field(serializers.CharField(allow_null=True))
|
||||
def get_draftBody(self, instance): # pylint: disable=invalid-name
|
||||
"""Return an arbitrary JSON object representing the draft body."""
|
||||
return (
|
||||
|
||||
@@ -29,7 +29,8 @@ export interface Message {
|
||||
readonly updated_at: string;
|
||||
readonly htmlBody: readonly MessageHtmlBodyItem[];
|
||||
readonly textBody: readonly MessageTextBodyItem[];
|
||||
readonly draftBody: string;
|
||||
/** @nullable */
|
||||
readonly draftBody: string | null;
|
||||
readonly attachments: readonly Attachment[];
|
||||
readonly sender: Contact;
|
||||
readonly to: readonly Contact[];
|
||||
|
||||
@@ -145,7 +145,7 @@ export const MessageForm = ({
|
||||
}
|
||||
|
||||
const formDefaultValues = useMemo(() => {
|
||||
const [draftBody, draftDriveAttachments] = MailHelper.extractDriveAttachmentsFromDraft(draft?.draftBody);
|
||||
const [draftBody, draftDriveAttachments] = MailHelper.extractDriveAttachmentsFromDraft(draft?.draftBody ?? '');
|
||||
return {
|
||||
from: defaultSenderId ?? '',
|
||||
to: draft?.to?.map(contact => contact.email) ?? recipients,
|
||||
|
||||
Reference in New Issue
Block a user