mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
compose: Add trigger for new private message.
This commit adds a new trigger for compose.start that is "new private message". It will clear the message recipients whenever compose.start is called with this trigger. This solves the bug, when a person is in a PM narrow and clicks the new private message button, it opens the composebox with the recipients filled out with whoever you're narrowed to, rather than opening a new, blank PM. CZO link for the issue https://chat.zulip.org/#narrow/stream/9-issues/topic/.22New.20private.20message.22.20isn't/near/1222712
This commit is contained in:
@@ -200,6 +200,17 @@ test("start", ({override}) => {
|
||||
assert.equal(compose_state.get_message_type(), "private");
|
||||
assert.ok(compose_state.composing());
|
||||
|
||||
// Triggered by new private message
|
||||
opts = {
|
||||
trigger: "new private message",
|
||||
};
|
||||
|
||||
start("private", opts);
|
||||
|
||||
assert.equal(compose_state.private_message_recipient(), "");
|
||||
assert.equal(compose_state.get_message_type(), "private");
|
||||
assert.ok(compose_state.composing());
|
||||
|
||||
// Cancel compose.
|
||||
let pill_cleared;
|
||||
compose_pm_pill.clear = () => {
|
||||
|
||||
@@ -223,7 +223,11 @@ export function start(msg_type, opts) {
|
||||
// If we are invoked by a compose hotkey (c or x) or new topic
|
||||
// button, do not assume that we know what the message's topic or
|
||||
// PM recipient should be.
|
||||
if (opts.trigger === "compose_hotkey" || opts.trigger === "new topic button") {
|
||||
if (
|
||||
opts.trigger === "compose_hotkey" ||
|
||||
opts.trigger === "new topic button" ||
|
||||
opts.trigger === "new private message"
|
||||
) {
|
||||
opts.topic = "";
|
||||
opts.private_message_recipient = "";
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ export function initialize() {
|
||||
});
|
||||
|
||||
$("body").on("click", ".compose_private_button", () => {
|
||||
compose_actions.start("private");
|
||||
compose_actions.start("private", {trigger: "new private message"});
|
||||
});
|
||||
|
||||
$("body").on("click", ".compose_reply_button", () => {
|
||||
|
||||
Reference in New Issue
Block a user