Files
webmail/lib/empty-folder-text.ts
T
Linus Rath 0a09fec123 fix: offer Empty Trash and Empty Spam only there, with the message count, and drop folder actions that can't apply
The folder menu tests no longer expect "Empty folder" on a folder of
your own: emptying is offered on Trash and Spam only now. The Mountain
View list test expects the entry to read "Empty Trash".
2026-11-04 11:30:11 +01:00

39 lines
1.3 KiB
TypeScript

/**
* What "Empty Trash" / "Empty Spam" is called and what its confirm says, as
* keys of the root catalogue. The confirm counts the messages that go
* (usability test 2026-11-04, p2-14). Other folders keep the old wording:
* nothing in the app offers to empty them, but a plugin can still ask.
*/
export function emptyFolderLabelKey(role: string | null | undefined): string | null {
if (role === "trash") return "mail_p2_folders.empty_trash";
if (role === "junk") return "mail_p2_folders.empty_spam";
return null;
}
export interface EmptyFolderPrompt {
title: string;
message: string;
values?: Record<string, number>;
confirm: string;
}
export function emptyFolderPrompt(
mailbox: { role?: string | null; totalEmails?: number },
movesToTrash: boolean,
): EmptyFolderPrompt {
const label = emptyFolderLabelKey(mailbox.role);
if (label) {
return {
title: label,
message: mailbox.role === "trash" ? "mail_p2_folders.empty_trash_confirm" : "mail_p2_folders.empty_spam_confirm",
values: { count: mailbox.totalEmails ?? 0 },
confirm: label,
};
}
return {
title: "email_list.empty_folder.confirm_title",
message: movesToTrash ? "email_list.empty_folder.confirm_message_trash" : "email_list.empty_folder.confirm_message",
confirm: "email_list.empty_folder.confirm_button",
};
}