Reactions: Skip notifications about self reactions (#1753)
This commit is contained in:
parent
790f2b613a
commit
59ea096c7b
@ -491,7 +491,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only notify about added reactions, not removed ones
|
// Only notify about added reactions, not removed ones
|
||||||
const shouldNotify = checkIfReactionAdded(currentReactions, reactions);
|
const shouldNotify = checkIfReactionAdded(currentReactions, reactions, global.currentUserId);
|
||||||
|
|
||||||
global = updateChatMessage(global, chatId, id, { reactions: update.reactions });
|
global = updateChatMessage(global, chatId, id, { reactions: update.reactions });
|
||||||
|
|
||||||
|
|||||||
@ -5,4 +5,4 @@ export * from './messageSummary';
|
|||||||
export * from './messageMedia';
|
export * from './messageMedia';
|
||||||
export * from './localSearch';
|
export * from './localSearch';
|
||||||
export * from './payments';
|
export * from './payments';
|
||||||
export { getMessageRecentReaction } from './reactions';
|
export * from './reactions';
|
||||||
|
|||||||
@ -4,9 +4,11 @@ export function getMessageRecentReaction(message: Partial<ApiMessage>) {
|
|||||||
return message.isOutgoing ? message.reactions?.recentReactions?.[0] : undefined;
|
return message.isOutgoing ? message.reactions?.recentReactions?.[0] : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function checkIfReactionAdded(oldReactions?: ApiReactions, newReactions?: ApiReactions) {
|
export function checkIfReactionAdded(oldReactions?: ApiReactions, newReactions?: ApiReactions, currentUserId?: string) {
|
||||||
if (!oldReactions || !oldReactions.recentReactions) return true;
|
if (!oldReactions || !oldReactions.recentReactions) return true;
|
||||||
if (!newReactions || !newReactions.recentReactions) return false;
|
if (!newReactions || !newReactions.recentReactions) return false;
|
||||||
|
// Skip reactions from yourself
|
||||||
|
if (newReactions.recentReactions.every(reaction => reaction.userId === currentUserId)) return false;
|
||||||
const oldReactionsMap = oldReactions.results.reduce<Record<string, number>>((acc, reaction) => {
|
const oldReactionsMap = oldReactions.results.reduce<Record<string, number>>((acc, reaction) => {
|
||||||
acc[reaction.reaction] = reaction.count;
|
acc[reaction.reaction] = reaction.count;
|
||||||
return acc;
|
return acc;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user