FIX: Loading draft also replaces the recipients (#7122)

This commit is contained in:
Bianca Nenciu 2019-03-06 23:14:55 +02:00 committed by Sam
parent 078c02cd24
commit 733deba585
3 changed files with 348 additions and 1 deletions

View File

@ -902,7 +902,7 @@ export default Ember.Controller.extend({
composerModel.set("composeState", Composer.OPEN);
composerModel.set("isWarning", false);
if (opts.usernames) {
if (opts.usernames && !this.get("model.targetUsernames")) {
this.set("model.targetUsernames", opts.usernames);
}

View File

@ -600,6 +600,24 @@ QUnit.test("Checks for existing draft", async assert => {
toggleCheckDraftPopup(false);
});
QUnit.test("Loading draft also replaces the recipients", async assert => {
toggleCheckDraftPopup(true);
// prettier-ignore
server.get("/draft.json", () => { // eslint-disable-line no-undef
return [ 200, { "Content-Type": "application/json" }, {
"draft":"{\"reply\":\"hello\",\"action\":\"privateMessage\",\"title\":\"hello\",\"categoryId\":null,\"archetypeId\":\"private_message\",\"metaData\":null,\"usernames\":\"codinghorror\",\"composerTime\":9159,\"typingTime\":2500}",
"draft_sequence":0
} ];
});
await visit("/u/charlie");
await click("button.compose-pm");
await click(".modal .btn-default");
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
});
const assertImageResized = (assert, uploads) => {
assert.equal(
find(".d-editor-input").val(),

View File

@ -2276,5 +2276,334 @@ export default {
}
]
}
},
"/u/charlie.json": {
user_badges: [
{
id: 17,
granted_at: "2019-03-06T19:08:28.230Z",
count: 1,
badge_id: 3,
user_id: 5,
granted_by_id: -1
}
],
badges: [
{
id: 3,
name: "Regular",
description:
'\u003ca href="https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/"\u003eGranted\u003c/a\u003e recategorize, rename, followed links, wiki, more likes',
grant_count: 3,
allow_title: true,
multiple_grant: false,
icon: "fa-user",
image: null,
listable: true,
enabled: true,
badge_grouping_id: 4,
system: true,
slug: "regular",
manually_grantable: false,
badge_type_id: 2
}
],
badge_types: [{ id: 2, name: "Silver", sort_order: 8 }],
users: [
{
id: 5,
username: "charlie",
name: null,
avatar_template: "/letter_avatar_proxy/v3/letter/c/d6d6ee/{size}.png",
moderator: false,
admin: false
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
moderator: true,
admin: true
}
],
user: {
id: 5,
username: "charlie",
name: null,
avatar_template: "/letter_avatar_proxy/v3/letter/c/d6d6ee/{size}.png",
last_posted_at: null,
last_seen_at: null,
created_at: "2019-03-06T19:06:20.340Z",
can_edit: true,
can_edit_username: true,
can_edit_email: true,
can_edit_name: true,
ignored: false,
can_ignore_user: false,
can_send_private_messages: true,
can_send_private_message_to_user: true,
trust_level: 3,
moderator: false,
admin: false,
title: null,
uploaded_avatar_id: null,
badge_count: 3,
has_title_badges: true,
custom_fields: {},
pending_count: 0,
profile_view_count: 1,
time_read: 0,
recent_time_read: 0,
primary_group_name: null,
primary_group_flair_url: null,
primary_group_flair_bg_color: null,
primary_group_flair_color: null,
staged: false,
second_factor_enabled: false,
post_count: 0,
can_be_deleted: true,
can_delete_all_posts: true,
locale: null,
muted_category_ids: [],
watched_tags: [],
watching_first_post_tags: [],
tracked_tags: [],
muted_tags: [],
tracked_category_ids: [],
watched_category_ids: [],
watched_first_post_category_ids: [],
system_avatar_upload_id: null,
system_avatar_template:
"/letter_avatar_proxy/v3/letter/c/d6d6ee/{size}.png",
muted_usernames: [],
ignored_usernames: [],
mailing_list_posts_per_day: 0,
can_change_bio: true,
user_api_keys: null,
user_auth_tokens: [],
user_auth_token_logs: [],
invited_by: null,
groups: [
{
id: 10,
automatic: true,
name: "trust_level_0",
display_name: "trust_level_0",
user_count: 14,
mentionable_level: 0,
messageable_level: 0,
visibility_level: 0,
automatic_membership_email_domains: null,
automatic_membership_retroactive: false,
primary_group: false,
title: null,
grant_trust_level: null,
incoming_email: null,
has_messages: false,
flair_url: null,
flair_bg_color: null,
flair_color: null,
bio_raw: null,
bio_cooked: null,
public_admission: false,
public_exit: false,
allow_membership_requests: false,
full_name: null,
default_notification_level: 3,
membership_request_template: null
},
{
id: 11,
automatic: true,
name: "trust_level_1",
display_name: "trust_level_1",
user_count: 9,
mentionable_level: 0,
messageable_level: 0,
visibility_level: 0,
automatic_membership_email_domains: null,
automatic_membership_retroactive: false,
primary_group: false,
title: null,
grant_trust_level: null,
incoming_email: null,
has_messages: false,
flair_url: null,
flair_bg_color: null,
flair_color: null,
bio_raw: null,
bio_cooked: null,
public_admission: false,
public_exit: false,
allow_membership_requests: false,
full_name: null,
default_notification_level: 3,
membership_request_template: null
},
{
id: 12,
automatic: true,
name: "trust_level_2",
display_name: "trust_level_2",
user_count: 6,
mentionable_level: 0,
messageable_level: 0,
visibility_level: 0,
automatic_membership_email_domains: null,
automatic_membership_retroactive: false,
primary_group: false,
title: null,
grant_trust_level: null,
incoming_email: null,
has_messages: false,
flair_url: null,
flair_bg_color: null,
flair_color: null,
bio_raw: null,
bio_cooked: null,
public_admission: false,
public_exit: false,
allow_membership_requests: false,
full_name: null,
default_notification_level: 3,
membership_request_template: null
},
{
id: 13,
automatic: true,
name: "trust_level_3",
display_name: "trust_level_3",
user_count: 3,
mentionable_level: 0,
messageable_level: 0,
visibility_level: 0,
automatic_membership_email_domains: null,
automatic_membership_retroactive: false,
primary_group: false,
title: null,
grant_trust_level: null,
incoming_email: null,
has_messages: false,
flair_url: null,
flair_bg_color: null,
flair_color: null,
bio_raw: null,
bio_cooked: null,
public_admission: false,
public_exit: false,
allow_membership_requests: false,
full_name: null,
default_notification_level: 3,
membership_request_template: null
}
],
group_users: [
{ group_id: 10, user_id: 5, notification_level: 3 },
{ group_id: 11, user_id: 5, notification_level: 3 },
{ group_id: 12, user_id: 5, notification_level: 3 },
{ group_id: 13, user_id: 5, notification_level: 3 }
],
featured_user_badge_ids: [17],
user_option: {
user_id: 5,
email_always: false,
mailing_list_mode: false,
mailing_list_mode_frequency: 1,
email_digests: true,
email_private_messages: true,
email_direct: true,
external_links_in_new_tab: false,
dynamic_favicon: false,
enable_quoting: true,
disable_jump_reply: false,
digest_after_minutes: 10080,
automatically_unpin_topics: true,
auto_track_topics_after_msecs: 240000,
notification_level_when_replying: 2,
new_topic_duration_minutes: 2880,
email_previous_replies: 2,
email_in_reply_to: true,
like_notification_frequency: 1,
include_tl0_in_digests: false,
theme_ids: [2],
theme_key_seq: 0,
allow_private_messages: true,
homepage_id: null,
hide_profile_and_presence: false,
text_size: "normal",
text_size_seq: 0
}
}
},
"/u/charlie/summary.json": {
topics: [],
badges: [
{
id: 3,
name: "Regular",
description:
'\u003ca href="https://blog.discourse.org/2018/06/understanding-discourse-trust-levels/"\u003eGranted\u003c/a\u003e recategorize, rename, followed links, wiki, more likes',
grant_count: 3,
allow_title: true,
multiple_grant: false,
icon: "fa-user",
image: null,
listable: true,
enabled: true,
badge_grouping_id: 4,
system: true,
slug: "regular",
manually_grantable: false,
badge_type_id: 2
}
],
badge_types: [{ id: 2, name: "Silver", sort_order: 8 }],
users: [
{
id: 5,
username: "charlie",
name: null,
avatar_template: "/letter_avatar_proxy/v3/letter/c/d6d6ee/{size}.png",
moderator: false,
admin: false
},
{
id: -1,
username: "system",
name: "system",
avatar_template: "/user_avatar/localhost/system/{size}/2_2.png",
moderator: true,
admin: true
}
],
user_summary: {
likes_given: 0,
likes_received: 0,
topics_entered: 0,
posts_read_count: 0,
days_visited: 0,
topic_count: 0,
post_count: 0,
time_read: 0,
recent_time_read: 0,
topic_ids: [],
replies: [],
links: [],
most_liked_by_users: [],
most_liked_users: [],
most_replied_to_users: [],
badges: [
{
id: 17,
granted_at: "2019-03-06T19:08:28.230Z",
count: 1,
badge_id: 3,
user_id: 5,
granted_by_id: -1
}
],
top_categories: []
}
}
};