hotkeys: Add u hotkey for opening message sender profile.

Fixes #4873
This commit is contained in:
Cynthia Lin
2017-05-23 11:01:24 -07:00
committed by showell
parent a45c224fda
commit a9afe43735
4 changed files with 42 additions and 23 deletions

View File

@@ -148,7 +148,7 @@ function stubbing(func_name_to_stub, test_function) {
// Unmapped keys should immediately return false, without
// calling any functions outside of hotkey.js.
assert_unmapped('abefhlmoptuxyz');
assert_unmapped('abefhlmoptxyz');
assert_unmapped('BEFHILNOQTUWXYZ');
// We have to skip some checks due to the way the code is
@@ -215,7 +215,7 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('d', 'drafts.toggle');
// Next, test keys that only work on a selected message.
var message_view_only_keys = '@*+rRjJkKsSvi:GM';
var message_view_only_keys = '@*+rRjJkKsSuvi:GM';
// Check that they do nothing without a selected message
global.current_msg_list.empty = return_true;
@@ -225,7 +225,7 @@ function stubbing(func_name_to_stub, test_function) {
// Check that they do nothing while in the settings overlay
overlays.settings_open = return_true;
assert_unmapped('@*+rRjJkKsSvi:GM');
assert_unmapped('@*+rRjJkKsSuvi:GM');
overlays.settings_open = return_false;
// TODO: Similar check for being in the subs page
@@ -241,6 +241,7 @@ function stubbing(func_name_to_stub, test_function) {
assert_mapping('K', 'navigate.page_up');
assert_mapping('s', 'narrow.by_recipient');
assert_mapping('S', 'narrow.by_subject');
assert_mapping('u', 'popovers.show_sender_info');
assert_mapping('v', 'lightbox.show_from_selected_message');
assert_mapping('i', 'popovers.open_message_menu');
assert_mapping(':', 'emoji_picker.toggle_emoji_popover', true);

View File

@@ -106,6 +106,7 @@ var keypress_mappings = {
113: {name: 'query_users', message_view_only: false}, // 'q'
114: {name: 'reply_message', message_view_only: true}, // 'r'
115: {name: 'narrow_by_recipient', message_view_only: true}, // 's'
117: {name: 'show_sender_info', message_view_only: true}, // 'u'
118: {name: 'show_lightbox', message_view_only: true}, // 'v'
119: {name: 'query_streams', message_view_only: false}, // 'w'
};
@@ -652,6 +653,9 @@ exports.process_hotkey = function (e, hotkey) {
case 'show_lightbox':
lightbox.show_from_selected_message();
return true;
case 'show_sender_info':
popovers.show_sender_info();
return true;
case 'open_reactions': // ':': open reactions to message
open_reactions();
return true;

View File

@@ -307,6 +307,20 @@ exports.hide_user_sidebar_popover = function () {
}
};
exports.show_sender_info = function () {
var message = $(".selected_message");
var sender = message.find(".sender_info_hover");
var prev_message = message.prev();
while (!sender[0]) {
prev_message = prev_message.prev();
if (!prev_message) {
break;
}
sender = prev_message.find(".sender_info_hover");
}
show_message_info_popover(sender[0], rows.id(message));
};
exports.register_click_handlers = function () {
$("#main_div").on("click", ".actions_hover", function (e) {
var row = $(this).closest(".message_row");

View File

@@ -6,32 +6,32 @@
<div class="messagebox-border">
<div class="messagebox-content">
<div class="message_top_line">
{{#include_sender}}
<span class="message_sender{{^status_message}} sender_info_hover{{/status_message}}">
{{! See ../js/notifications.js for another user of avatar_url. }}
<div class="u-{{msg/sender_id}} inline_profile_picture{{#status_message}} sender_info_hover{{/status_message}}"
style="background-image: url('{{small_avatar_url}}');"/>
{{#if status_message}}
<span class="sender-status">
<span class="sender_name-in-status sender_info_hover">{{msg/sender_full_name}}</span>
{{#include_sender}}
{{! See ../js/notifications.js for another user of avatar_url. }}
<div class="u-{{msg/sender_id}} inline_profile_picture{{#status_message}} sender_info_hover{{/status_message}}"
style="background-image: url('{{small_avatar_url}}');"/>
{{#if status_message}}
<span class="sender-status">
<span class="sender_name-in-status sender_info_hover">{{msg/sender_full_name}}</span>
{{#if sender_is_bot}}
<img class="bot-icon" title="{{t 'Bot' }}" src="/static/images/bot.svg" />
{{/if}}
<span class="status-message">
{{{ status_message }}}
</span>
{{#if_and last_edit_timestr include_sender}}
<div class="message_edit_notice" title="{{#tr this}}Edited (__last_edit_timestr__){{/tr}}">{{t "EDITED" }}</div>
{{/if_and}}
</span>
{{else}}
<span class="sender_name">{{msg/sender_full_name}}</span>
{{#if sender_is_bot}}
<img class="bot-icon" title="{{t 'Bot' }}" src="/static/images/bot.svg" />
{{/if}}
<span class="status-message">
{{{ status_message }}}
</span>
{{#if_and last_edit_timestr include_sender}}
<div class="message_edit_notice" title="{{#tr this}}Edited (__last_edit_timestr__){{/tr}}">{{t "EDITED" }}</div>
{{/if_and}}
</span>
{{else}}
<span class="sender_name">{{msg/sender_full_name}}</span>
{{#if sender_is_bot}}
<img class="bot-icon" title="{{t 'Bot' }}" src="/static/images/bot.svg" />
{{/if}}
{{/if}}
{{/include_sender}}
</span>
{{/include_sender}}
<span class="alert-copied pull-right">{{t 'Copied!' }}</span>
<span class="message_time{{#if msg.local_id}} notvisible{{/if}}{{#if status_message}} status-time{{/if}}">{{timestr}}</span>
{{#if_and last_edit_timestr include_sender}}