recent_topics: Make it the default view.

Go to Recent Topics on "#", no hash and "#recent_topics".
Go to Recent Topics as the last destination for escape key.
Map `a` key to All messages and change its hash to
`#all_messages`.
This commit is contained in:
Aman Agrawal
2020-09-20 13:44:24 +05:30
committed by Tim Abbott
parent dda36d1c93
commit 39d123e355
23 changed files with 56 additions and 38 deletions

View File

@@ -53,7 +53,7 @@ streams.)
### Unnarrow: previous sequence ### Unnarrow: previous sequence
When you unnarrow using e.g. the escape key, you will automatically be When you unnarrow using e.g. the `a` key, you will automatically be
taken to the same message that was selected in the All messages view before taken to the same message that was selected in the All messages view before
you narrowed, unless in the narrow you read new messages, in which you narrowed, unless in the narrow you read new messages, in which
case you will be jumped forward to the first unread and non-muted case you will be jumped forward to the first unread and non-muted

View File

@@ -51,7 +51,7 @@ Try using all the navigation hotkeys:
Try narrowing from the message view: Try narrowing from the message view:
- Hotkeys - Hotkeys
- use Esc to go to All messages - use a to go to All messages
- use s to narrow to a stream (select message first - use s to narrow to a stream (select message first
and verify in sidebar) and verify in sidebar)
- use S to narrow to the topic (and verify in sidebar) - use S to narrow to the topic (and verify in sidebar)
@@ -63,7 +63,7 @@ Try narrowing from the message view:
- narrow to a group PM - narrow to a group PM
- Click on the Zulip logo - Click on the Zulip logo
- narrow to a topic - narrow to a topic
- click on the Zulip logo (and verify you're in the All messages view) - click on the Zulip logo (and verify you're in the Recent topics view)
### Messagebox ### ### Messagebox ###

View File

@@ -19,6 +19,7 @@ const hashchange = zrequire("hashchange");
const stream_data = zrequire("stream_data"); const stream_data = zrequire("stream_data");
zrequire("navigate"); zrequire("navigate");
zrequire("recent_topics"); zrequire("recent_topics");
recent_topics.show = () => {};
set_global("search", { set_global("search", {
update_button_visibility: () => {}, update_button_visibility: () => {},
@@ -38,6 +39,9 @@ const overlays = set_global("overlays", {});
const settings = set_global("settings", {}); const settings = set_global("settings", {});
const subs = set_global("subs", {}); const subs = set_global("subs", {});
const ui_util = set_global("ui_util", {}); const ui_util = set_global("ui_util", {});
set_global("top_left_corner", {
handle_narrow_deactivated: () => {},
});
run_test("operators_round_trip", () => { run_test("operators_round_trip", () => {
let operators; let operators;
@@ -161,7 +165,7 @@ function test_helper() {
run_test("hash_interactions", () => { run_test("hash_interactions", () => {
const helper = test_helper(); const helper = test_helper();
window.location.hash = "#"; window.location.hash = "#all_messages";
helper.clear_events(); helper.clear_events();
hashchange.initialize(); hashchange.initialize();

View File

@@ -19,6 +19,10 @@ const {run_test} = require("../zjsunit/test");
// it calls any external module other than `ui.foo`, it'll crash. // it calls any external module other than `ui.foo`, it'll crash.
// Future work includes making sure it actually does call `ui.foo()`. // Future work includes making sure it actually does call `ui.foo()`.
// Since all the tests here are based on narrow starting with all_messages.
// We set our default narrow to all messages here.
window.location.hash = "#all_messages";
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json"); const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
set_global("navigator", { set_global("navigator", {
@@ -206,7 +210,7 @@ run_test("basic_chars", () => {
// Unmapped keys should immediately return false, without // Unmapped keys should immediately return false, without
// calling any functions outside of hotkey.js. // calling any functions outside of hotkey.js.
assert_unmapped("abfmoyz"); assert_unmapped("bfmoyz");
assert_unmapped("BEFHILNOQTUWXYZ"); assert_unmapped("BEFHILNOQTUWXYZ");
// We have to skip some checks due to the way the code is // We have to skip some checks due to the way the code is

View File

@@ -227,7 +227,7 @@ class CommonUtils {
await this.fill_form(page, "#login_form", params); await this.fill_form(page, "#login_form", params);
await page.$eval("#login_form", (form) => (form as HTMLFormElement).submit()); await page.$eval("#login_form", (form) => (form as HTMLFormElement).submit());
await page.waitForSelector("#zhome .message_row", {visible: true}); await page.waitForSelector("#recent_topics_filter_buttons", {visible: true});
} }
async log_out(page: Page): Promise<void> { async log_out(page: Page): Promise<void> {

View File

@@ -76,7 +76,7 @@ async function un_narrow(page: Page): Promise<void> {
if (await page.evaluate(() => $(".message_comp").is(":visible"))) { if (await page.evaluate(() => $(".message_comp").is(":visible"))) {
await page.keyboard.press("Escape"); await page.keyboard.press("Escape");
} }
await page.keyboard.press("Escape"); await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true}); await page.waitForSelector("#zhome .message_row", {visible: true});
assert.strictEqual(await page.title(), "home - Zulip Dev - Zulip"); assert.strictEqual(await page.title(), "home - Zulip Dev - Zulip");
} }
@@ -414,6 +414,8 @@ async function test_users_search(page: Page): Promise<void> {
async function message_basic_tests(page: Page): Promise<void> { async function message_basic_tests(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
console.log("Sending messages"); console.log("Sending messages");
await common.send_multiple_messages(page, [ await common.send_multiple_messages(page, [

View File

@@ -142,7 +142,7 @@ async function test_send_multirecipient_pm_from_cordelia_pm_narrow(page: Page):
}); });
// Go back to all messages view and make sure all messages are loaded. // Go back to all messages view and make sure all messages are loaded.
await page.keyboard.press("Escape"); await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true}); await page.waitForSelector("#zhome .message_row", {visible: true});
await page.waitForFunction((selector: string) => $(selector).length !== 0, {}, pm_selector); await page.waitForFunction((selector: string) => $(selector).length !== 0, {}, pm_selector);
@@ -216,6 +216,8 @@ async function test_markdown_preview(page: Page): Promise<void> {
async function compose_tests(page: Page): Promise<void> { async function compose_tests(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await test_send_messages(page); await test_send_messages(page);
await test_keyboard_shortcuts(page); await test_keyboard_shortcuts(page);
await test_reply_by_click_prepopulates_stream_topic_names(page); await test_reply_by_click_prepopulates_stream_topic_names(page);

View File

@@ -31,12 +31,14 @@ async function test_narrow_to_starred_messages(page: Page): Promise<void> {
await common.check_messages_sent(page, "zfilt", [["Verona > stars", [message]]]); await common.check_messages_sent(page, "zfilt", [["Verona > stars", [message]]]);
// Go back to all messages narrow. // Go back to all messages narrow.
await page.keyboard.press("Escape"); await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true}); await page.waitForSelector("#zhome .message_row", {visible: true});
} }
async function stars_test(page: Page): Promise<void> { async function stars_test(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await common.send_message(page, "stream", { await common.send_message(page, "stream", {
stream: "Verona", stream: "Verona",
topic: "stars", topic: "stars",

View File

@@ -78,6 +78,8 @@ async function test_edit_private_message(page: Page): Promise<void> {
async function edit_tests(page: Page): Promise<void> { async function edit_tests(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await test_stream_message_edit(page); await test_stream_message_edit(page);
await test_edit_message_with_slash_me(page); await test_edit_message_with_slash_me(page);

View File

@@ -5,7 +5,7 @@ import type {Page} from "puppeteer";
import common from "../puppeteer_lib/common"; import common from "../puppeteer_lib/common";
async function wait_for_tab(page: Page, tab: string): Promise<void> { async function wait_for_tab(page: Page, tab: string): Promise<void> {
const tab_slector = `#${CSS.escape(tab)}.tab-pane.active`; const tab_slector = `#${CSS.escape(tab)}.tab-pane`;
await page.waitForSelector(tab_slector, {visible: true}); await page.waitForSelector(tab_slector, {visible: true});
} }
@@ -89,7 +89,7 @@ async function navigation_tests(page: Page): Promise<void> {
await wait_for_tab(page, "message_feed_container"); await wait_for_tab(page, "message_feed_container");
await navigate_to_subscriptions(page); await navigate_to_subscriptions(page);
await navigate_to(page, "", "message_feed_container"); await navigate_to(page, "all_messages", "message_feed_container");
await navigate_to_settings(page); await navigate_to_settings(page);
await navigate_to(page, "narrow/is/private", "message_feed_container"); await navigate_to(page, "narrow/is/private", "message_feed_container");
await navigate_to_subscriptions(page); await navigate_to_subscriptions(page);

View File

@@ -6,6 +6,8 @@ import common from "../puppeteer_lib/common";
async function test_mention(page: Page): Promise<void> { async function test_mention(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await page.keyboard.press("KeyC"); await page.keyboard.press("KeyC");
await page.waitForSelector("#compose", {visible: true}); await page.waitForSelector("#compose", {visible: true});

View File

@@ -247,6 +247,8 @@ async function test_delete_draft_on_sending(page: Page): Promise<void> {
async function drafts_test(page: Page): Promise<void> { async function drafts_test(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await test_empty_drafts(page); await test_empty_drafts(page);

View File

@@ -13,6 +13,8 @@ async function click_delete_and_return_last_msg_id(page: Page): Promise<string |
async function delete_message_test(page: Page): Promise<void> { async function delete_message_test(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
const messages_quantitiy = await page.evaluate(() => $("#zhome .message_row").length); const messages_quantitiy = await page.evaluate(() => $("#zhome .message_row").length);
const last_message_id = await click_delete_and_return_last_msg_id(page); const last_message_id = await click_delete_and_return_last_msg_id(page);

View File

@@ -123,6 +123,8 @@ async function test_copying_messages_from_several_topics(page: Page): Promise<vo
async function copy_paste_test(page: Page): Promise<void> { async function copy_paste_test(page: Page): Promise<void> {
await common.log_in(page); await common.log_in(page);
await page.click(".top_left_all_messages");
await page.waitForSelector("#zhome .message_row", {visible: true});
await common.send_multiple_messages(page, [ await common.send_multiple_messages(page, [
{stream: "Verona", topic: "copy-paste-topic #1", content: "copy paste test A"}, {stream: "Verona", topic: "copy-paste-topic #1", content: "copy paste test A"},

View File

@@ -65,6 +65,7 @@ function activate_home_tab() {
const coming_from_recent_topics = maybe_hide_recent_topics(); const coming_from_recent_topics = maybe_hide_recent_topics();
ui_util.change_tab_to("#message_feed_container"); ui_util.change_tab_to("#message_feed_container");
narrow.deactivate(coming_from_recent_topics); narrow.deactivate(coming_from_recent_topics);
top_left_corner.handle_narrow_deactivated();
floating_recipient_bar.update(); floating_recipient_bar.update();
search.update_button_visibility(); search.update_button_visibility();
// We need to maybe scroll to the selected message // We need to maybe scroll to the selected message
@@ -111,7 +112,7 @@ function do_hashchange_normal(from_reload) {
if (operators === undefined) { if (operators === undefined) {
// If the narrow URL didn't parse, clear // If the narrow URL didn't parse, clear
// window.location.hash and send them to the home tab // window.location.hash and send them to the home tab
set_hash(""); set_hash("#all_messages");
activate_home_tab(); activate_home_tab();
return false; return false;
} }
@@ -133,11 +134,12 @@ function do_hashchange_normal(from_reload) {
} }
case "": case "":
case "#": case "#":
activate_home_tab();
break;
case "#recent_topics": case "#recent_topics":
recent_topics.show(); recent_topics.show();
break; break;
case "#all_messages":
activate_home_tab();
break;
case "#keyboard-shortcuts": case "#keyboard-shortcuts":
case "#message-formatting": case "#message-formatting":
case "#search-operators": case "#search-operators":

View File

@@ -98,6 +98,7 @@ const keypress_mappings = {
82: {name: "respond_to_author", message_view_only: true}, // 'R' 82: {name: "respond_to_author", message_view_only: true}, // 'R'
83: {name: "narrow_by_topic", message_view_only: true}, //'S' 83: {name: "narrow_by_topic", message_view_only: true}, //'S'
86: {name: "view_selected_stream", message_view_only: false}, //'V' 86: {name: "view_selected_stream", message_view_only: false}, //'V'
97: {name: "all_messages", message_view_only: true}, // 'a'
99: {name: "compose", message_view_only: true}, // 'c' 99: {name: "compose", message_view_only: true}, // 'c'
100: {name: "open_drafts", message_view_only: true}, // 'd' 100: {name: "open_drafts", message_view_only: true}, // 'd'
101: {name: "edit_message", message_view_only: true}, // 'e' 101: {name: "edit_message", message_view_only: true}, // 'e'
@@ -477,7 +478,7 @@ exports.process_hotkey = function (e, hotkey) {
case "tab": case "tab":
case "shift_tab": case "shift_tab":
if ( if (
window.location.hash === "#recent_topics" && ["#recent_topics", "#", ""].includes(window.location.hash) &&
!popovers.any_active() && !popovers.any_active() &&
!overlays.is_active() !overlays.is_active()
) { ) {
@@ -735,6 +736,9 @@ exports.process_hotkey = function (e, hotkey) {
case "open_recent_topics": case "open_recent_topics":
hashchange.go_to_location("#"); hashchange.go_to_location("#");
return true; return true;
case "all_messages":
hashchange.go_to_location("#all_messages");
return true;
} }
// We don't want hotkeys below this to work when recent topics is // We don't want hotkeys below this to work when recent topics is

View File

@@ -770,7 +770,7 @@ function handle_post_narrow_deactivate_processes() {
exports.deactivate = function (coming_from_recent_topics = false) { exports.deactivate = function (coming_from_recent_topics = false) {
// NOTE: Never call this function independently, // NOTE: Never call this function independently,
// always use hashchange.go_to_location("") to // always use hashchange.go_to_location("#all_messages") to
// activate All message narrow. // activate All message narrow.
/* /*
Switches current_msg_list from narrowed_msg_list to Switches current_msg_list from narrowed_msg_list to

View File

@@ -503,13 +503,6 @@ exports.change_focused_element = function (e, input_key) {
// handle the key. // handle the key.
const $elem = $(e.target); const $elem = $(e.target);
if ($("#recent_topics_table").find(":focus").length === 0) {
// This is a failsafe to return focus back to recent topics overlay,
// in case it loses focus due to some unknown reason.
set_default_focus();
return false;
}
if (e.target.id === "recent_topics_search") { if (e.target.id === "recent_topics_search") {
// Since the search box a text area, we want the browser to handle // Since the search box a text area, we want the browser to handle
// Left/Right and selection within the widget; but if the user // Left/Right and selection within the widget; but if the user

View File

@@ -98,7 +98,7 @@
<div id="recent_topics_table"></div> <div id="recent_topics_table"></div>
</div> </div>
</div> </div>
<div class="tab-pane active" id="message_feed_container"> <div class="tab-pane" id="message_feed_container">
<div class="fixed-app" id="floating_recipient_bar"> <div class="fixed-app" id="floating_recipient_bar">
<div class="app-main recipient_bar_content"> <div class="app-main recipient_bar_content">
<div class="column-middle column-overlay recipient-bar-main"> <div class="column-middle column-overlay recipient-bar-main">

View File

@@ -177,7 +177,7 @@
</tr> </tr>
<tr> <tr>
<td class="definition">{% trans %}Narrow to all unmuted messages{% endtrans %}</td> <td class="definition">{% trans %}Narrow to all unmuted messages{% endtrans %}</td>
<td><span class="hotkey"><kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td> <td><span class="hotkey"><kbd>A</kbd></span></td>
</tr> </tr>
<tr> <tr>
<td class="definition">{% trans %}Narrow to current compose box recipient{% endtrans %}</td> <td class="definition">{% trans %}Narrow to current compose box recipient{% endtrans %}</td>
@@ -241,11 +241,7 @@
</thead> </thead>
<tr> <tr>
<td class="definition">{% trans %}View recent topics{% endtrans %}</td> <td class="definition">{% trans %}View recent topics{% endtrans %}</td>
<td><span class="hotkey"><kbd>T</kbd></span></td> <td><span class="hotkey"><kbd>T</kbd> or <kbd>Esc</kbd> or <kbd>Ctrl</kbd> + <kbd>[</kbd></span></td>
</tr>
<tr>
<td class="definition">{% trans %}Hide recent topics{% endtrans %}</td>
<td><span class="hotkey"><kbd>Esc</kbd></span></td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@@ -2,8 +2,8 @@
<div class="narrows_panel"> <div class="narrows_panel">
<ul id="global_filters" class="filters"> <ul id="global_filters" class="filters">
{# Special-case this link so we don't actually go to page top. #} {# Special-case this link so we don't actually go to page top. #}
<li class="top_left_all_messages top_left_row active-filter" title="{{ _('All messages') }} (Esc)"> <li class="top_left_all_messages top_left_row" title="{{ _('All messages') }} (a)">
<a href="#" class="home-link"> <a href="#all_messages" class="home-link">
<span class="filter-icon"> <span class="filter-icon">
<i class="fa fa-home" aria-hidden="true"></i> <i class="fa fa-home" aria-hidden="true"></i>
</span> </span>
@@ -57,7 +57,7 @@
<span class="arrow starred-messages-sidebar-menu-icon"><i class="zulip-icon ellipsis-v-solid" aria-hidden="true"></i></span> <span class="arrow starred-messages-sidebar-menu-icon"><i class="zulip-icon ellipsis-v-solid" aria-hidden="true"></i></span>
</li> </li>
<li class="top_left_recent_topics top_left_row"> <li class="top_left_recent_topics top_left_row">
<a href="#recent_topics"> <a href="#">
<span class="filter-icon"> <span class="filter-icon">
<i class="fa fa-clock-o" aria-hidden="true"></i> <i class="fa fa-clock-o" aria-hidden="true"></i>
</span> </span>

View File

@@ -76,7 +76,7 @@ below, and add more to your repertoire as needed.
* **Cycle between stream narrows**: `A` (previous) and `D` (next) * **Cycle between stream narrows**: `A` (previous) and `D` (next)
* **Narrow to all messages**: `Esc` or `Ctrl` + `[` — Shows all unmuted messages. * **Narrow to all messages**: `a` — Shows all unmuted messages.
* **Narrow to current compose box recipient**: `Ctrl` + `.` * **Narrow to current compose box recipient**: `Ctrl` + `.`
@@ -139,8 +139,7 @@ title="thumbs up"/>**: `+`
## Recent topics ## Recent topics
* **View recent topics**: `t` * **View recent topics**: `t` or `Esc` or `Ctrl` + `[`
* **Hide recent topics**: `Esc`
Keyboard navigation (e.g. arrow keys) works as expected. Keyboard navigation (e.g. arrow keys) works as expected.
Use `Enter` to engage with elements. Use `Enter` to engage with elements.

View File

@@ -45,10 +45,10 @@ magnifying glass next to `STREAMS`, or by using the autocomplete in
If you're all caught up, it can be useful to have a single place to keep If you're all caught up, it can be useful to have a single place to keep
track of all messages coming in. track of all messages coming in.
* Click on **All messages** in the upper left, or hit `Esc`. * Click on **All messages** in the upper left, or hit `a`.
* You can use `s` (narrow to stream) or `S` (narrow to topic) to zoom in, * You can use `s` (narrow to stream) or `S` (narrow to topic) to zoom in,
and `Esc` to get back to All messages. and `a` to get back to All messages.
## Starring messages for later ## Starring messages for later