From a2b4db07f6ab23b6a289405fce95a44c177316e2 Mon Sep 17 00:00:00 2001 From: Daniil Fadeev Date: Mon, 11 Sep 2023 13:59:27 +0400 Subject: [PATCH] emoji_picker: Move module event registration to initialization. --- web/src/click_handlers.js | 1 - web/src/emoji_picker.js | 3 ++- web/tests/emoji_picker.test.js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/click_handlers.js b/web/src/click_handlers.js index 778d60b7bd..c7f8c59786 100644 --- a/web/src/click_handlers.js +++ b/web/src/click_handlers.js @@ -658,7 +658,6 @@ export function initialize() { popovers.register_click_handlers(); user_profile.register_click_handlers(); - emoji_picker.register_click_handlers(); stream_popover.register_click_handlers(); $("body").on("click", ".logout_button", () => { diff --git a/web/src/emoji_picker.js b/web/src/emoji_picker.js index 25b0ad1bbd..c7fe6591ac 100644 --- a/web/src/emoji_picker.js +++ b/web/src/emoji_picker.js @@ -695,7 +695,7 @@ export function toggle_emoji_popover(target, id, additional_popover_options) { {show_as_overlay}, ); } -export function register_click_handlers() { +function register_click_handlers() { $(document).on("click", ".emoji-popover-emoji.reaction", function (e) { // When an emoji is clicked in the popover, // if the user has reacted to this message with this emoji @@ -824,4 +824,5 @@ export function register_click_handlers() { export function initialize() { rebuild_catalog(); + register_click_handlers(); } diff --git a/web/tests/emoji_picker.test.js b/web/tests/emoji_picker.test.js index 3164fd853b..6ed98f8866 100644 --- a/web/tests/emoji_picker.test.js +++ b/web/tests/emoji_picker.test.js @@ -4,7 +4,7 @@ const {strict: assert} = require("assert"); const _ = require("lodash"); -const {zrequire} = require("./lib/namespace"); +const {zrequire, set_global} = require("./lib/namespace"); const {run_test} = require("./lib/test"); const emoji = zrequire("emoji"); @@ -12,6 +12,8 @@ const emoji_picker = zrequire("emoji_picker"); const emoji_codes = zrequire("../../static/generated/emoji/emoji_codes.json"); +set_global("document", "document-stub"); + run_test("initialize", () => { emoji.initialize({ realm_emoji: {},