mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 21:48:30 +00:00
Track what user action triggered a narrow
(imported from commit 2b110dc27334e4b823810bfef13c3d10d36b3886)
This commit is contained in:
@@ -118,7 +118,8 @@ function do_hashchange() {
|
|||||||
}
|
}
|
||||||
narrow.activate(operators, {
|
narrow.activate(operators, {
|
||||||
select_first_unread: true,
|
select_first_unread: true,
|
||||||
change_hash: false // already set
|
change_hash: false, // already set
|
||||||
|
trigger: 'hash change'
|
||||||
});
|
});
|
||||||
ui.update_floating_recipient_bar();
|
ui.update_floating_recipient_bar();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ var directional_hotkeys_id = {
|
|||||||
var narrow_hotkeys = {
|
var narrow_hotkeys = {
|
||||||
115: narrow.by_recipient, // 's'
|
115: narrow.by_recipient, // 's'
|
||||||
83: narrow.by_subject, // 'S'
|
83: narrow.by_subject, // 'S'
|
||||||
118: function () { // 'v'
|
118: function (target, opts) { // 'v'
|
||||||
narrow.by('is', 'private-message');
|
narrow.by('is', 'private-message', opts);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ function process_hotkey(e) {
|
|||||||
if (current_msg_list.empty()) {
|
if (current_msg_list.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
narrow_hotkeys[code](current_msg_list.selected_id());
|
narrow_hotkeys[code](current_msg_list.selected_id(), {trigger: 'hotkey'});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -349,7 +349,8 @@ exports.activate = function (operators, opts) {
|
|||||||
opts = $.extend({}, {
|
opts = $.extend({}, {
|
||||||
then_select_id: home_msg_list.selected_id(),
|
then_select_id: home_msg_list.selected_id(),
|
||||||
select_first_unread: false,
|
select_first_unread: false,
|
||||||
change_hash: true
|
change_hash: true,
|
||||||
|
trigger: 'unknown'
|
||||||
}, opts);
|
}, opts);
|
||||||
|
|
||||||
if (opts.then_select_id === -1) {
|
if (opts.then_select_id === -1) {
|
||||||
@@ -459,7 +460,8 @@ exports.activate = function (operators, opts) {
|
|||||||
compose.update_faded_messages();
|
compose.update_faded_messages();
|
||||||
|
|
||||||
$(document).trigger($.Event('narrow_activated.zephyr', {msg_list: narrowed_msg_list,
|
$(document).trigger($.Event('narrow_activated.zephyr', {msg_list: narrowed_msg_list,
|
||||||
filter: current_filter}));
|
filter: current_filter,
|
||||||
|
trigger: opts.trigger}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Activate narrowing with a single operator.
|
// Activate narrowing with a single operator.
|
||||||
@@ -468,36 +470,39 @@ exports.by = function (operator, operand, opts) {
|
|||||||
exports.activate([[operator, operand]], opts);
|
exports.activate([[operator, operand]], opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_subject = function (target_id) {
|
exports.by_subject = function (target_id, opts) {
|
||||||
var original = current_msg_list.get(target_id);
|
var original = current_msg_list.get(target_id);
|
||||||
if (original.type !== 'stream') {
|
if (original.type !== 'stream') {
|
||||||
// Only stream messages have subjects, but the
|
// Only stream messages have subjects, but the
|
||||||
// user wants us to narrow in some way.
|
// user wants us to narrow in some way.
|
||||||
exports.by_recipient(target_id);
|
exports.by_recipient(target_id, opts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
opts = $.extend({}, {then_select_id: target_id}, opts);
|
||||||
exports.activate([
|
exports.activate([
|
||||||
['stream', original.stream],
|
['stream', original.stream],
|
||||||
['subject', original.subject]
|
['subject', original.subject]
|
||||||
], { then_select_id: target_id });
|
], opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Called for the 'narrow by stream' hotkey.
|
// Called for the 'narrow by stream' hotkey.
|
||||||
exports.by_recipient = function (target_id) {
|
exports.by_recipient = function (target_id, opts) {
|
||||||
|
opts = $.extend({}, {then_select_id: target_id}, opts);
|
||||||
var message = current_msg_list.get(target_id);
|
var message = current_msg_list.get(target_id);
|
||||||
switch (message.type) {
|
switch (message.type) {
|
||||||
case 'private':
|
case 'private':
|
||||||
exports.by('pm-with', message.reply_to, { then_select_id: target_id });
|
exports.by('pm-with', message.reply_to, opts);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'stream':
|
case 'stream':
|
||||||
exports.by('stream', message.stream, { then_select_id: target_id });
|
exports.by('stream', message.stream, opts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.by_time_travel = function (target_id) {
|
exports.by_time_travel = function (target_id, opts) {
|
||||||
narrow.activate([], { then_select_id: target_id });
|
opts = $.extend({}, {then_select_id: target_id}, opts);
|
||||||
|
narrow.activate([], opts);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.deactivate = function () {
|
exports.deactivate = function () {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ function narrow_or_search_for_term(item) {
|
|||||||
ui.change_tab_to('#home');
|
ui.change_tab_to('#home');
|
||||||
switch (obj.action) {
|
switch (obj.action) {
|
||||||
case 'stream':
|
case 'stream':
|
||||||
narrow.by('stream', obj.query);
|
narrow.by('stream', obj.query, {trigger: 'search'});
|
||||||
// It's sort of annoying that this is not in a position to
|
// It's sort of annoying that this is not in a position to
|
||||||
// blur the search box, because it means that Esc won't
|
// blur the search box, because it means that Esc won't
|
||||||
// unnarrow, it'll leave the searchbox.
|
// unnarrow, it'll leave the searchbox.
|
||||||
@@ -123,17 +123,17 @@ function narrow_or_search_for_term(item) {
|
|||||||
return search_query_box.val();
|
return search_query_box.val();
|
||||||
|
|
||||||
case 'private_message':
|
case 'private_message':
|
||||||
narrow.by('pm-with', obj.query.email);
|
narrow.by('pm-with', obj.query.email, {trigger: 'search'});
|
||||||
search_query_box.blur();
|
search_query_box.blur();
|
||||||
return search_query_box.val();
|
return search_query_box.val();
|
||||||
|
|
||||||
case 'sender':
|
case 'sender':
|
||||||
narrow.by('sender', obj.query.email);
|
narrow.by('sender', obj.query.email, {trigger: 'search'});
|
||||||
search_query_box.blur();
|
search_query_box.blur();
|
||||||
return search_query_box.val();
|
return search_query_box.val();
|
||||||
|
|
||||||
case 'operators':
|
case 'operators':
|
||||||
narrow.activate(obj.operators);
|
narrow.activate(obj.operators, {trigger: 'search'});
|
||||||
search_query_box.blur();
|
search_query_box.blur();
|
||||||
return search_query_box.val();
|
return search_query_box.val();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1121,9 +1121,9 @@ $(function () {
|
|||||||
var nearest = current_msg_list.get(rows.id($(this).closest(".recipient_row")));
|
var nearest = current_msg_list.get(rows.id($(this).closest(".recipient_row")));
|
||||||
var selected = current_msg_list.selected_message();
|
var selected = current_msg_list.selected_message();
|
||||||
if (util.same_recipient(nearest, selected)) {
|
if (util.same_recipient(nearest, selected)) {
|
||||||
narrow.by_recipient(selected.id);
|
narrow.by_recipient(selected.id, {trigger: 'message header'});
|
||||||
} else {
|
} else {
|
||||||
narrow.by_recipient(nearest.id);
|
narrow.by_recipient(nearest.id, {trigger: 'message header'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1131,9 +1131,9 @@ $(function () {
|
|||||||
var nearest = current_msg_list.get(rows.id($(this).closest(".recipient_row")));
|
var nearest = current_msg_list.get(rows.id($(this).closest(".recipient_row")));
|
||||||
var selected = current_msg_list.selected_message();
|
var selected = current_msg_list.selected_message();
|
||||||
if (util.same_recipient(nearest, selected)) {
|
if (util.same_recipient(nearest, selected)) {
|
||||||
narrow.by_subject(selected.id);
|
narrow.by_subject(selected.id, {trigger: 'message header'});
|
||||||
} else {
|
} else {
|
||||||
narrow.by_subject(nearest.id);
|
narrow.by_subject(nearest.id, {trigger: 'message header'});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1233,7 +1233,7 @@ $(function () {
|
|||||||
ui.change_tab_to('#home');
|
ui.change_tab_to('#home');
|
||||||
}
|
}
|
||||||
var stream = $(e.target).parents('li').attr('data-name');
|
var stream = $(e.target).parents('li').attr('data-name');
|
||||||
narrow.by('stream', stream, {select_first_unread: true});
|
narrow.by('stream', stream, {select_first_unread: true, trigger: 'sidebar'});
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
@@ -1264,7 +1264,7 @@ $(function () {
|
|||||||
|
|
||||||
narrow.activate([['stream', stream],
|
narrow.activate([['stream', stream],
|
||||||
['subject', subject]],
|
['subject', subject]],
|
||||||
{select_first_unread: true});
|
{select_first_unread: true, trigger: 'sidebar'});
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
@@ -1343,26 +1343,26 @@ $(function () {
|
|||||||
$('body').on('click', '.popover_narrow_by_subject_button', function (e) {
|
$('body').on('click', '.popover_narrow_by_subject_button', function (e) {
|
||||||
var msgid = $(e.currentTarget).data('msgid');
|
var msgid = $(e.currentTarget).data('msgid');
|
||||||
ui.hide_actions_popover();
|
ui.hide_actions_popover();
|
||||||
narrow.by_subject(msgid);
|
narrow.by_subject(msgid, {trigger: 'popover'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_narrow_by_recipient_button', function (e) {
|
$('body').on('click', '.popover_narrow_by_recipient_button', function (e) {
|
||||||
var msgid = $(e.currentTarget).data('msgid');
|
var msgid = $(e.currentTarget).data('msgid');
|
||||||
ui.hide_actions_popover();
|
ui.hide_actions_popover();
|
||||||
narrow.by_recipient(msgid);
|
narrow.by_recipient(msgid, {trigger: 'popover'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_narrow_by_sender_button', function (e) {
|
$('body').on('click', '.popover_narrow_by_sender_button', function (e) {
|
||||||
var msgid = $(e.currentTarget).data('msgid');
|
var msgid = $(e.currentTarget).data('msgid');
|
||||||
var sender_email = $(e.currentTarget).data('sender_email');
|
var sender_email = $(e.currentTarget).data('sender_email');
|
||||||
ui.hide_actions_popover();
|
ui.hide_actions_popover();
|
||||||
narrow.by('sender', sender_email, {then_select_id: msgid});
|
narrow.by('sender', sender_email, {then_select_id: msgid, trigger: 'popover'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_narrow_by_time_travel_button', function (e) {
|
$('body').on('click', '.popover_narrow_by_time_travel_button', function (e) {
|
||||||
var msgid = $(e.currentTarget).data('msgid');
|
var msgid = $(e.currentTarget).data('msgid');
|
||||||
ui.hide_actions_popover();
|
ui.hide_actions_popover();
|
||||||
narrow.by_time_travel(msgid);
|
narrow.by_time_travel(msgid, {trigger: 'popover'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_toggle_collapse', function (e) {
|
$('body').on('click', '.popover_toggle_collapse', function (e) {
|
||||||
@@ -1415,7 +1415,7 @@ $(function () {
|
|||||||
$('body').on('click', '.narrow_to_stream', function (e) {
|
$('body').on('click', '.narrow_to_stream', function (e) {
|
||||||
var stream = $(e.currentTarget).parents('ul').attr('data-name');
|
var stream = $(e.currentTarget).parents('ul').attr('data-name');
|
||||||
ui.hide_sidebar_popover();
|
ui.hide_sidebar_popover();
|
||||||
narrow.by('stream', stream, {select_first_unread: true});
|
narrow.by('stream', stream, {select_first_unread: true, trigger: 'sidebar popover'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user