hotkey: Add keyboard shortcut to navigate to starred messages view.

This commit adds '*' as a keyboard shortcut to navigate to the starred messages view and the shortcut is documented in various required locations accordingly.
Fixes #31397.
This commit is contained in:
opmkumar 2024-08-23 23:28:23 +05:30 committed by Tim Abbott
parent 5f6045c878
commit 8911347cdb
8 changed files with 24 additions and 23 deletions

View File

@ -11,6 +11,11 @@
You can also [search your starred messages](/help/search-for-messages)
using the `is:starred` filter.
!!! keyboard_tip ""
Use <kbd>*</kbd> to view your starred messages.
{tab|mobile}
1. Tap the **Starred messages**

View File

@ -108,6 +108,8 @@ in the Zulip app to add more to your repertoire as needed.
* **Go to combined feed**: <kbd>A</kbd> — Shows all unmuted messages.
* **Go to starred messages**: <kbd>*</kbd>
* **Go to the conversation you are composing to**: <kbd>Ctrl</kbd> + <kbd>.</kbd>
## Composing messages

View File

@ -1,7 +1,6 @@
import {z} from "zod";
import * as blueslip from "./blueslip";
import * as common from "./common";
import * as dialog_widget from "./dialog_widget";
import {$t_html} from "./i18n";
import {localstorage} from "./localstorage";
@ -23,14 +22,10 @@ let shown_deprecation_notices: string[] = [];
export function maybe_show_deprecation_notice(key: string): void {
let message;
const isCmdOrCtrl = common.has_mac_keyboard() ? "Cmd" : "Ctrl";
switch (key) {
case "Shift + C":
message = get_hotkey_deprecation_notice("Shift + C", "X");
break;
case "*":
message = get_hotkey_deprecation_notice("*", isCmdOrCtrl + " + S");
break;
case "Shift + S":
message = get_hotkey_deprecation_notice("Shift + S", "S");
break;

View File

@ -150,7 +150,7 @@ const keydown_either_mappings = {
};
const keypress_mappings = {
42: {name: "star_deprecated", message_view_only: true}, // '*'
42: {name: "open_starred_message_view", message_view_only: true}, // '*'
43: {name: "thumbs_up_emoji", message_view_only: true}, // '+'
61: {name: "upvote_first_emoji", message_view_only: true}, // '='
45: {name: "toggle_message_collapse", message_view_only: true}, // '-'
@ -996,6 +996,9 @@ export function process_hotkey(e, hotkey) {
case "open_inbox":
browser_history.go_to_location("#inbox");
return true;
case "open_starred_message_view":
browser_history.go_to_location("#narrow/is/starred");
return true;
case "open_combined_feed":
browser_history.go_to_location("#feed");
return true;
@ -1044,9 +1047,6 @@ export function process_hotkey(e, hotkey) {
case "C_deprecated":
deprecated_feature_notice.maybe_show_deprecation_notice("Shift + C");
return true;
case "star_deprecated":
deprecated_feature_notice.maybe_show_deprecation_notice("*");
return true;
}
// Hotkeys below this point are for the message feed, and so

View File

@ -171,6 +171,10 @@
<td class="definition">{{t 'Go to combined feed' }}</td>
<td><span class="hotkey"><kbd>A</kbd></span></td>
</tr>
<tr>
<td class="definition">{{t 'Go to starred messages' }}</td>
<td><span class="hotkey"><kbd>*</kbd></span></td>
</tr>
<tr>
<td class="definition">{{t 'Go to the conversation you are composing to' }}</td>
<td><span class="hotkey"><kbd>Ctrl</kbd> + <kbd>.</kbd></span></td>

View File

@ -109,7 +109,7 @@
</a>
</li>
<li class="top_left_starred_messages top_left_row hidden-for-spectators">
<a class="left-sidebar-navigation-label-container" href="#narrow/is/starred">
<a class="left-sidebar-navigation-label-container tippy-views-tooltip" href="#narrow/is/starred" data-tooltip-template-id="starred-message-tooltip-template">
<span class="filter-icon">
<i class="zulip-icon zulip-icon-star-filled" aria-hidden="true"></i>
</span>

View File

@ -117,6 +117,12 @@
</div>
{{tooltip_hotkey_hints "T"}}
</template>
<template id="starred-message-tooltip-template">
<div class="views-tooltip-container">
<div>{{t 'Starred messages' }}</div>
</div>
{{tooltip_hotkey_hints "*"}}
</template>
<template id="my-reactions-tooltip-template">
<div class="views-tooltip-container" data-view-code="recent_topics">
<div>{{t 'Reactions to your messages' }}</div>

View File

@ -13,18 +13,7 @@ const deprecated_feature_notice = zrequire("deprecated_feature_notice");
run_test("get_hotkey_deprecation_notice", () => {
const expected =
'translated HTML: We\'ve replaced the "*" hotkey with "Ctrl + s" to make this common shortcut easier to trigger.';
const actual = deprecated_feature_notice.get_hotkey_deprecation_notice("*", "Ctrl + s");
'translated HTML: We\'ve replaced the "Shift + C" hotkey with "X" to make this common shortcut easier to trigger.';
const actual = deprecated_feature_notice.get_hotkey_deprecation_notice("Shift + C", "X");
assert.equal(actual, expected);
});
run_test("get_hotkey_deprecation_notice_mac", () => {
navigator.userAgent =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36";
const expected =
'translated HTML: We\'ve replaced the "*" hotkey with "Cmd + s" to make this common shortcut easier to trigger.';
const actual = deprecated_feature_notice.get_hotkey_deprecation_notice("*", "Cmd + s");
assert.equal(actual, expected);
// Reset userAgent
navigator.userAgent = "";
});