Skip to content

Commit 145fdc9

Browse files
committed
fix: check if text is undefined before rending plain text
1 parent 18d97a9 commit 145fdc9

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/batch/batch.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ export class Batch {
4141
);
4242
}
4343
}
44-
const [html, text] = await Promise.all([
45-
this.renderAsync(email.react as React.ReactElement),
46-
this.renderAsync(email.react as React.ReactElement, {
47-
plainText: true,
48-
}),
49-
]);
44+
const reactElement = email.react as React.ReactElement;
45+
const html = await this.renderAsync(reactElement);
5046
email.html = html;
51-
email.text = text;
47+
if (email.text === undefined) {
48+
email.text = await this.renderAsync(reactElement, {
49+
plainText: true,
50+
});
51+
}
5252
email.react = undefined;
5353
}
5454

src/emails/emails.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ export class Emails {
5252
}
5353

5454
const reactElement = payload.react as React.ReactElement;
55-
const [html, text] = await Promise.all([
56-
this.renderAsync(reactElement),
57-
this.renderAsync(reactElement, {
58-
plainText: true,
59-
}),
60-
]);
61-
payload.text = text;
55+
const html = await this.renderAsync(reactElement);
6256
payload.html = html;
57+
if (payload.text === undefined) {
58+
payload.text = await this.renderAsync(reactElement, {
59+
plainText: true,
60+
});
61+
}
6362
}
6463

6564
const data = await this.resend.post<CreateEmailResponseSuccess>(

0 commit comments

Comments
 (0)