compose: Show counter inside Drafts button for the current recipient.

Now we show the number of drafts that are addressed to the current
recipient selected in the compose box, if any, in the Drafts button
within parentheses (whether it is next to the Send button, or in the
Send options popover), and explain that it is the number of drafts for
this conversation in the tooltip.

Fixes: #28696.
This commit is contained in:
N-Shar-ma
2024-02-07 12:44:58 +05:30
committed by Tim Abbott
parent 6ec04c2469
commit f4d58f1ba6
13 changed files with 78 additions and 19 deletions

View File

@@ -157,6 +157,7 @@ export const draft_model = (function () {
ls.set(KEY, drafts);
if (update_count) {
set_count(Object.keys(drafts).length);
update_compose_draft_count();
}
}
@@ -208,6 +209,24 @@ export const draft_model = (function () {
};
})();
export function update_compose_draft_count(): void {
const $count_container = $(".compose-drafts-count-container");
const $count_ele = $count_container.find(".compose-drafts-count");
if (!compose_state.has_full_recipient()) {
$count_ele.text("");
$count_container.hide();
return;
}
const compose_draft_count = Object.keys(filter_drafts_by_compose_box_and_recipient()).length;
if (compose_draft_count > 0) {
$count_ele.text(compose_draft_count > 99 ? "99+" : compose_draft_count);
$count_container.show();
} else {
$count_ele.text("");
$count_container.hide();
}
}
export function sync_count(): void {
const drafts = draft_model.get();
set_count(Object.keys(drafts).length);