mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user