FEATURE: One-click chat reaction settings (#32150)

Adds a one-click chat reactions setting to the chat preferences page
where members can determine what one-click reactions are shown in chat.

- Frequent: This will be the default setting. (Automatically set based
on most used chat reactions)
- Custom: Members can choose up to three reactions they want to see in
their one-click chat/DM reactions menu. Defaults are `❤️`, `👍` ,
and `😄`.


![image](https://github.com/user-attachments/assets/8913db0e-d6ec-4347-ad91-2329206b127c)

This pull request is essentially the work of @dsims in
https://github.com/discourse/discourse/pull/31761

---------

Co-authored-by: dsims <1041068+dsims@users.noreply.github.com>
This commit is contained in:
Joffrey JAFFEUX
2025-04-04 09:15:13 +02:00
committed by GitHub
parent 33748895a9
commit 4c8420833e
16 changed files with 431 additions and 40 deletions

View File

@ -54,6 +54,8 @@ after_initialize do
DiscoursePluginRegistry.register_flag_applies_to_type("Chat::Message", self)
UserUpdater::OPTION_ATTR.push(:chat_enabled)
UserUpdater::OPTION_ATTR.push(:chat_quick_reaction_type)
UserUpdater::OPTION_ATTR.push(:chat_quick_reactions_custom)
UserUpdater::OPTION_ATTR.push(:only_chat_push_notifications)
UserUpdater::OPTION_ATTR.push(:chat_sound)
UserUpdater::OPTION_ATTR.push(:ignore_channel_wide_mention)
@ -251,6 +253,18 @@ after_initialize do
add_to_serializer(:current_user_option, :chat_send_shortcut) { object.chat_send_shortcut }
add_to_serializer(:user_option, :chat_quick_reaction_type) { object.chat_quick_reaction_type }
add_to_serializer(:current_user_option, :chat_quick_reaction_type) do
object.chat_quick_reaction_type
end
add_to_serializer(:user_option, :chat_quick_reactions_custom) do
object.chat_quick_reactions_custom
end
add_to_serializer(:current_user_option, :chat_quick_reactions_custom) do
object.chat_quick_reactions_custom
end
on(:site_setting_changed) do |name, old_value, new_value|
user_option_field = Chat::RETENTION_SETTINGS_TO_USER_OPTION_FIELDS[name.to_sym]
begin