fix: use full tag path in drag-drop toasts, fresh email in context menu markAsRead
Nested tag toasts from drag-and-drop only showed the leaf name for non-root tags, contradicting the comment above it and making two same-named leaves under different parents (e.g. Personal/Receipts vs Work/Receipts) indistinguishable in the toast. The context menu's markAsRead handler was the one action left reading the stale contextMenu.data instead of the live-refreshed contextMenuEmail introduced alongside it, so it could act on outdated email state while every sibling handler was already updated.
This commit is contained in:
@@ -598,7 +598,7 @@ export function EmailList({
|
|||||||
onReplyAll={() => onReplyAll?.(contextMenuEmail!)}
|
onReplyAll={() => onReplyAll?.(contextMenuEmail!)}
|
||||||
onForward={() => onForward?.(contextMenuEmail!)}
|
onForward={() => onForward?.(contextMenuEmail!)}
|
||||||
onForwardAsAttachment={() => onForwardAsAttachment?.(contextMenuEmail!)}
|
onForwardAsAttachment={() => onForwardAsAttachment?.(contextMenuEmail!)}
|
||||||
onMarkAsRead={(read) => onMarkAsRead?.(contextMenu.data!, read)}
|
onMarkAsRead={(read) => onMarkAsRead?.(contextMenuEmail!, read)}
|
||||||
onToggleStar={() => onToggleStar?.(contextMenuEmail!)}
|
onToggleStar={() => onToggleStar?.(contextMenuEmail!)}
|
||||||
onTogglePinned={onTogglePinned ? () => onTogglePinned(contextMenuEmail!) : undefined}
|
onTogglePinned={onTogglePinned ? () => onTogglePinned(contextMenuEmail!) : undefined}
|
||||||
onDelete={() => onDelete?.(contextMenuEmail!)}
|
onDelete={() => onDelete?.(contextMenuEmail!)}
|
||||||
|
|||||||
@@ -609,21 +609,26 @@ function TagItem({
|
|||||||
// Nested rows are placed by their indentation, so they show their own name.
|
// Nested rows are placed by their indentation, so they show their own name.
|
||||||
// A root spells out its path, which matters when an intermediate tag is
|
// A root spells out its path, which matters when an intermediate tag is
|
||||||
// missing from this client's settings and the row would otherwise read as a
|
// missing from this client's settings and the row would otherwise read as a
|
||||||
// bare leaf name. Toasts have the room for the whole thing.
|
// bare leaf name.
|
||||||
const labelCandidates = node.depth === 0 ? tagNameCandidates(node.id) : [node.label];
|
const labelCandidates = node.depth === 0 ? tagNameCandidates(node.id) : [node.label];
|
||||||
const label = labelCandidates[0];
|
const label = labelCandidates[0];
|
||||||
|
// Toasts have the room for the whole thing, and no indentation to lean on,
|
||||||
|
// so they always spell out the full path - otherwise two leaves with the
|
||||||
|
// same name in different branches (e.g. "Personal/Receipts" and
|
||||||
|
// "Work/Receipts") would read as the same tag.
|
||||||
|
const fullLabel = tagNameCandidates(node.id)[0];
|
||||||
const { isDragging: globalDragging } = useDragDropContext();
|
const { isDragging: globalDragging } = useDragDropContext();
|
||||||
const { dropHandlers, isValidDropTarget } = useTagDrop({
|
const { dropHandlers, isValidDropTarget } = useTagDrop({
|
||||||
tagId: node.id,
|
tagId: node.id,
|
||||||
onSuccess: (count) => {
|
onSuccess: (count) => {
|
||||||
if (count === 1) {
|
if (count === 1) {
|
||||||
toast.success(t('email_tagged'), label);
|
toast.success(t('email_tagged'), fullLabel);
|
||||||
} else {
|
} else {
|
||||||
toast.success(t('emails_tagged', { count }), label);
|
toast.success(t('emails_tagged', { count }), fullLabel);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t('tag_failed'), label);
|
toast.error(t('tag_failed'), fullLabel);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user