mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
popovers: Add sidebar menu to delete all drafts.
This provides a convenient interface to hide all drafts. Fixes #19360. However, we may want to continue to implement a button in the drafts overlay as well for doing this operation.
This commit is contained in:
committed by
Tim Abbott
parent
4207f0a299
commit
32f206e1e5
@@ -3,6 +3,7 @@ import Handlebars from "handlebars/runtime";
|
||||
import $ from "jquery";
|
||||
import tippy from "tippy.js";
|
||||
|
||||
import render_confirm_delete_all_drafts from "../templates/confirm_dialog/confirm_delete_all_drafts.hbs";
|
||||
import render_draft_table_body from "../templates/draft_table_body.hbs";
|
||||
|
||||
import * as blueslip from "./blueslip";
|
||||
@@ -13,7 +14,8 @@ import * as compose_actions from "./compose_actions";
|
||||
import * as compose_fade from "./compose_fade";
|
||||
import * as compose_state from "./compose_state";
|
||||
import * as compose_ui from "./compose_ui";
|
||||
import {$t} from "./i18n";
|
||||
import * as confirm_dialog from "./confirm_dialog";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
import {localstorage} from "./localstorage";
|
||||
import * as markdown from "./markdown";
|
||||
import * as narrow from "./narrow";
|
||||
@@ -90,6 +92,23 @@ export const draft_model = (function () {
|
||||
return exports;
|
||||
})();
|
||||
|
||||
export function delete_all_drafts() {
|
||||
const drafts = draft_model.get();
|
||||
for (const [id] of Object.entries(drafts)) {
|
||||
draft_model.deleteDraft(id);
|
||||
}
|
||||
}
|
||||
|
||||
export function confirm_delete_all_drafts() {
|
||||
const html_body = render_confirm_delete_all_drafts();
|
||||
|
||||
confirm_dialog.launch({
|
||||
html_heading: $t_html({defaultMessage: "Delete all drafts"}),
|
||||
html_body,
|
||||
on_click: delete_all_drafts,
|
||||
});
|
||||
}
|
||||
|
||||
export function snapshot_message() {
|
||||
if (!compose_state.composing() || compose_state.message_content().length <= 2) {
|
||||
// If you aren't in the middle of composing the body of a
|
||||
|
||||
Reference in New Issue
Block a user