Reactions: Play reaction if it is put by another user (#4273)
This commit is contained in:
parent
7b73ef8d03
commit
ae9d09c762
@ -59,6 +59,7 @@ import {
|
|||||||
selectIsServiceChatReady,
|
selectIsServiceChatReady,
|
||||||
selectIsViewportNewest,
|
selectIsViewportNewest,
|
||||||
selectListedIds,
|
selectListedIds,
|
||||||
|
selectPerformanceSettingsValue,
|
||||||
selectPinnedIds,
|
selectPinnedIds,
|
||||||
selectSavedDialogIdFromMessage,
|
selectSavedDialogIdFromMessage,
|
||||||
selectScheduledIds,
|
selectScheduledIds,
|
||||||
@ -222,7 +223,9 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
const newMessage = selectChatMessage(global, chatId, id)!;
|
const newMessage = selectChatMessage(global, chatId, id)!;
|
||||||
|
|
||||||
if (message.reactions && chat) {
|
if (message.reactions && chat) {
|
||||||
global = updateReactions(global, chatId, id, message.reactions, chat, newMessage.isOutgoing, currentMessage);
|
global = updateReactions(
|
||||||
|
global, actions, chatId, id, message.reactions, chat, newMessage.isOutgoing, currentMessage,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.content?.text?.text !== currentMessage?.content?.text?.text) {
|
if (message.content?.text?.text !== currentMessage?.content?.text?.text) {
|
||||||
@ -620,7 +623,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
|
|
||||||
if (!chat || !message) return;
|
if (!chat || !message) return;
|
||||||
|
|
||||||
global = updateReactions(global, chatId, id, reactions, chat, message.isOutgoing, message);
|
global = updateReactions(global, actions, chatId, id, reactions, chat, message.isOutgoing, message);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -706,6 +709,7 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
|
|
||||||
function updateReactions<T extends GlobalState>(
|
function updateReactions<T extends GlobalState>(
|
||||||
global: T,
|
global: T,
|
||||||
|
actions: RequiredGlobalActions,
|
||||||
chatId: string,
|
chatId: string,
|
||||||
id: number,
|
id: number,
|
||||||
reactions: ApiReactions,
|
reactions: ApiReactions,
|
||||||
@ -726,6 +730,14 @@ function updateReactions<T extends GlobalState>(
|
|||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { reaction, isOwn, isUnread } = reactions.recentReactions?.[0] ?? {};
|
||||||
|
const reactionEffectsEnabled = selectPerformanceSettingsValue(global, 'reactionEffects');
|
||||||
|
if (reactionEffectsEnabled && message && reaction && isUnread && !isOwn) {
|
||||||
|
const messageKey = getMessageKey(message);
|
||||||
|
// Start reaction only in master tab
|
||||||
|
actions.startActiveReaction({ containerId: messageKey, reaction, tabId: getCurrentTabId() });
|
||||||
|
}
|
||||||
|
|
||||||
const alreadyHasUnreadReaction = chat.unreadReactions?.includes(id);
|
const alreadyHasUnreadReaction = chat.unreadReactions?.includes(id);
|
||||||
|
|
||||||
// Only notify about added reactions, not removed ones
|
// Only notify about added reactions, not removed ones
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user