Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(email): Thread reply compose bug (#1682)

Evan Hutnikdf9e8cc78d85
diff --git a/js/app/packages/block-email/component/BaseInput.tsx b/js/app/packages/block-email/component/BaseInput.tsx
index 4d88133479..d355bf7452 100644
--- a/js/app/packages/block-email/component/BaseInput.tsx
+++ b/js/app/packages/block-email/component/BaseInput.tsx
@@ -305,6 +305,7 @@ function TruncatedRecipientList(props: {
}
type UndoReplySnapshot = {
+ threadId: string;
draftId: string;
bodyHtml: string;
attachments: DraftFormAttachment[];
@@ -379,11 +380,20 @@ export function BaseInput(props: {
const [showBcc, setShowBcc] = createSignal<boolean>();
const [savedDraftId, setSavedDraftId] = createSignal<
MessageToSendDbId | undefined
- >(props.draft?.db_id ?? undoReplySnapshot?.draftId ?? undefined);
+ >(
+ props.draft?.db_id ??
+ (undoReplySnapshot?.threadId === ctx.thread()?.db_id
+ ? undoReplySnapshot?.draftId
+ : undefined) ??
+ undefined
+ );
- // Consume undo-send snapshot if one exists (inline reply remount case).
+ // Consume undo-send snapshot if one exists and belongs to this thread (inline reply remount case).
// Use bodyHtml as initialHtml for the editor, restore attachments on mount.
- const restoredSnapshot = undoReplySnapshot;
+ const restoredSnapshot =
+ undoReplySnapshot?.threadId === ctx.thread()?.db_id
+ ? undoReplySnapshot
+ : null;
if (restoredSnapshot) {
undoReplySnapshot = null;
onMount(() => {
@@ -815,8 +825,10 @@ export function BaseInput(props: {
$generateHtmlFromNodes(currentEditor)
);
const snapshotDraftId = savedDraftId();
- if (snapshotDraftId) {
+ const snapshotThreadId = ctx.thread()?.db_id;
+ if (snapshotDraftId && snapshotThreadId) {
undoReplySnapshot = {
+ threadId: snapshotThreadId,
draftId: snapshotDraftId,
bodyHtml: snapshotHtml,
attachments: [...form().attachments.list()],