mirror of https://github.com/zulip/zulip.git
Use zephyr_dict as the authoritative source for data about zephyrs.
Previously we would extract zephyr data from a TR. In the NWO where sometimes this data is ommitted, we instead need to use the zephyr_dict object. (imported from commit a5f06bdadc4fbe13f1718d6dcb41046d0ed040cd)
This commit is contained in:
parent
4821175dd5
commit
17537ffe17
|
@ -173,33 +173,40 @@ function scroll_to_selected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function respond_to_zephyr() {
|
function respond_to_zephyr() {
|
||||||
var parent, zephyr_class, zephyr_huddle, zephyr_personal, zephyr_instance, next_zephyr;
|
var parent, zephyr;
|
||||||
var recipient, recipients;
|
var recipient, recipients;
|
||||||
parent = get_zephyr(selected_zephyr_id);
|
parent = get_zephyr(selected_zephyr_id);
|
||||||
zephyr_class = parent.find("span.zephyr_class").text();
|
zephyr = zephyr_dict[parent.attr('id')];
|
||||||
zephyr_huddle = parent.find("span.zephyr_huddle_recipient").text();
|
|
||||||
zephyr_personal = parent.find("span.zephyr_personal_recipient").text();
|
$('.zephyr_compose').slideToggle('fast');
|
||||||
zephyr_instance = parent.find("span.zephyr_instance").text();
|
|
||||||
if (zephyr_class !== '') {
|
if (zephyr.type === 'class') {
|
||||||
$('.zephyr_compose').slideToggle('fast');
|
|
||||||
$('#zephyr-type-tabs a[href="#class-message"]').tab('show');
|
$('#zephyr-type-tabs a[href="#class-message"]').tab('show');
|
||||||
$("#class").val(zephyr_class);
|
$("#class").val(zephyr.display_recipient);
|
||||||
$("#instance").val(zephyr_instance);
|
$("#instance").val(zephyr.instance);
|
||||||
$("#new_zephyr").focus();
|
$("#new_zephyr").focus();
|
||||||
$("#new_zephyr").select();
|
$("#new_zephyr").select();
|
||||||
} else if (zephyr_huddle !== '') {
|
} else if (zephyr.type === 'huddle') {
|
||||||
recipients = parent.find("span.zephyr_huddle_recipients_list").text();
|
$('#zephyr-type-tabs a[href="#personal-message"]').tab('show');
|
||||||
prepare_huddle(recipients);
|
recipient = '';
|
||||||
} else if (zephyr_personal !== '') {
|
for (i in zephyr.display_recipient) {
|
||||||
|
recipient += zephyr.display_recipient[i].name + ', ';
|
||||||
|
}
|
||||||
|
$("#recipient").val(recipient);
|
||||||
|
$("#new_personal_zephyr").focus();
|
||||||
|
$("#new_personal_zephyr").select();
|
||||||
|
} else if (zephyr.type === 'personal') {
|
||||||
// Until we allow sending zephyrs based on multiple meaningful
|
// Until we allow sending zephyrs based on multiple meaningful
|
||||||
// representations of a user (name, username, email, etc.), just
|
// representations of a user (name, username, email, etc.), just
|
||||||
// deal with usernames.
|
// deal with usernames.
|
||||||
recipient = parent.find("span.zephyr_sender_username").text();
|
recipient = zephyr.display_recipient;
|
||||||
if (recipient === username) { // that is, we sent the original message
|
if ( recipient === username) { // that is, we sent the original message
|
||||||
recipient = parent.find("span.zephyr_personal_recipient").text();
|
recipient = zephyr.sender;
|
||||||
}
|
}
|
||||||
prepare_huddle(recipient);
|
prepare_huddle(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_pointer(zephyr) {
|
function update_pointer(zephyr) {
|
||||||
|
@ -411,22 +418,22 @@ function narrow_all_personals() {
|
||||||
function narrow_personals() {
|
function narrow_personals() {
|
||||||
// Narrow to personals with a specific user
|
// Narrow to personals with a specific user
|
||||||
var target_zephyr = get_zephyr(selected_zephyr_id);
|
var target_zephyr = get_zephyr(selected_zephyr_id);
|
||||||
var target_recipient = target_zephyr.find("span.zephyr_personal_recipient").text();
|
var zephyr_obj = zephyr_dict[target_zephyr.attr('id')];
|
||||||
var target_sender = target_zephyr.find("span.zephyr_sender").text();
|
|
||||||
var other_party;
|
var other_party;
|
||||||
if (target_recipient === username) {
|
if (zephyr_obj.display_recipient === username) {
|
||||||
other_party = target_sender;
|
other_party = zephyr_obj.sender;
|
||||||
} else {
|
} else {
|
||||||
other_party = target_recipient;
|
other_party = zephyr_obj.display_recipient;
|
||||||
}
|
}
|
||||||
var message = "Huddles with " + other_party;
|
var message = "Huddles with " + other_party;
|
||||||
do_narrow(message, function (element) {
|
do_narrow(message, function (element) {
|
||||||
|
var other_zephyr_obj = zephyr_dict[target_zephyr.attr('id')];
|
||||||
var recipient = element.find("span.zephyr_personal_recipient");
|
var recipient = element.find("span.zephyr_personal_recipient");
|
||||||
var sender = element.find("span.zephyr_sender");
|
var sender = element.find("span.zephyr_sender");
|
||||||
|
|
||||||
return (recipient.length > 0) &&
|
return (recipient.length > 0) &&
|
||||||
(((recipient.text() === target_recipient) && (sender.text() === target_sender)) ||
|
(((other_zephyr_obj.display_recipient === zephyr_obj.display_recipient) && (other_zephyr_obj.sender === zephyr_obj.sender)) ||
|
||||||
((recipient.text() === target_sender) && (sender.text() === target_recipient)));
|
((other_zephyr_obj.display_recipient === zephyr_obj.sender) && (other_zephyr_obj.sender === zephyr_obj.display_recipient)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue