Fix persistent message selection across narrows

(imported from commit 958ce299108f8bbc8579e7446053d7fc9f018b81)
This commit is contained in:
Zev Benjamin 2012-10-15 12:57:24 -04:00
parent cd14988b47
commit b42cf1d4c8
4 changed files with 18 additions and 9 deletions

View File

@ -21,7 +21,7 @@ var globals =
+ ' process_goto_hotkey process_compose_hotkey process_key_in_input'
// narrow.js
+ ' narrowed show_all_messages'
+ ' narrow_target_message_id narrowed show_all_messages'
+ ' narrow_all_personals narrow_by_recipient narrow_subject'
// setup.js

View File

@ -23,16 +23,16 @@
<tr class="recipient_row">
<td colspan="2"
class="message_label_clickable message_newstyle_stream"
onclick="select_message_by_id({{id}}); narrow_stream();"
onclick="target_message_for_narrow({{id}}); narrow_stream();"
title="{{display_recipient}}">{{display_recipient}}</td>
<td class="message_label_clickable message_newstyle_subject"
onclick="select_message_by_id({{id}}); narrow_subject();"
onclick="target_message_for_narrow({{id}}); narrow_subject();"
title="{{subject}}">{{subject}}</td>
</tr>
{{else}}
<tr class="recipient_row">
<td colspan="3" class="message_label_clickable message_newstyle_pm"
onclick="select_message_by_id({{id}}); narrow_by_recipient();"
onclick="target_message_for_narrow({{id}}); narrow_huddle();"
title="Huddle with {{display_reply_to}}">Huddle with {{display_reply_to}}</td>
</tr>
{{/if}}

View File

@ -111,6 +111,8 @@ var goto_hotkeys = {
};
function process_goto_hotkey(code) {
narrow_target_message_id = selected_message_id;
if (goto_hotkeys.hasOwnProperty(code))
goto_hotkeys[code]();

View File

@ -1,6 +1,9 @@
// For tracking where you were before you narrowed.
var persistent_message_id = 0;
// For narrowing based on a particular message
var narrow_target_message_id = 0;
// Narrowing predicate, or 'false' for the home view.
var narrowed = false;
@ -23,12 +26,16 @@ function do_narrow(description, filter_function) {
$("#currently_narrowed_to").html(description).attr("title", description);
$("#zhome").removeClass("focused_table");
select_and_show_by_id(selected_message_id);
select_and_show_by_id(narrow_target_message_id);
scroll_to_selected();
}
function target_message_for_narrow(id) {
narrow_target_message_id = id;
}
function narrow_huddle() {
var original = message_dict[selected_message_id];
var original = message_dict[narrow_target_message_id];
do_narrow("Huddles with " + original.reply_to, function (other) {
return other.reply_to === original.reply_to;
});
@ -42,7 +49,7 @@ function narrow_all_personals() {
function narrow_personals() {
// Narrow to personals with a specific user
var original = message_dict[selected_message_id];
var original = message_dict[narrow_target_message_id];
var other_party;
if (original.display_recipient.email === email) {
other_party = original.sender_email;
@ -59,7 +66,7 @@ function narrow_personals() {
}
function narrow_stream() {
var original = message_dict[selected_message_id];
var original = message_dict[narrow_target_message_id];
var message = original.display_recipient;
do_narrow(message, function (other) {
return (other.type === 'stream' &&
@ -68,7 +75,7 @@ function narrow_stream() {
}
function narrow_subject() {
var original = message_dict[selected_message_id];
var original = message_dict[narrow_target_message_id];
if (original.type !== 'stream')
return;