mirror of https://github.com/zulip/zulip.git
ui_init: Initialize hotkey handlers after other libraries are initialized.
This gives us some time to render and fetch data before allowing user to start using hotkeys. It avoids error being thrown when hotkeys are used when the app is still loading.
This commit is contained in:
parent
e66f125ee6
commit
2d31b52927
|
@ -998,12 +998,6 @@ export function process_keydown(e) {
|
|||
return process_hotkey(e, hotkey);
|
||||
}
|
||||
|
||||
$(document).on("keydown", (e) => {
|
||||
if (process_keydown(e)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
export function process_keypress(e) {
|
||||
const hotkey = get_keypress_hotkey(e);
|
||||
if (!hotkey) {
|
||||
|
@ -1012,8 +1006,16 @@ export function process_keypress(e) {
|
|||
return process_hotkey(e, hotkey);
|
||||
}
|
||||
|
||||
$(document).on("keypress", (e) => {
|
||||
if (process_keypress(e)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
export function initialize() {
|
||||
$(document).on("keydown", (e) => {
|
||||
if (process_keydown(e)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("keypress", (e) => {
|
||||
if (process_keypress(e)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import * as emojisets from "./emojisets";
|
|||
import * as gear_menu from "./gear_menu";
|
||||
import * as giphy from "./giphy";
|
||||
import * as hashchange from "./hashchange";
|
||||
import * as hotkey from "./hotkey";
|
||||
import * as hotspots from "./hotspots";
|
||||
import * as i18n from "./i18n";
|
||||
import * as invite from "./invite";
|
||||
|
@ -687,6 +688,7 @@ export function initialize_everything() {
|
|||
user_status_ui.initialize();
|
||||
fenced_code.initialize(generated_pygments_data);
|
||||
message_edit_history.initialize();
|
||||
hotkey.initialize();
|
||||
|
||||
$("#app-loading").addClass("loaded");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue