A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
fix(app): keep mention highlight when mentions are suppressed (#3242)
Hampus6e28092cdced
diff --git a/fluxer_app/src/features/messaging/models/MessagingMessage.ts b/fluxer_app/src/features/messaging/models/MessagingMessage.tsindex e0e486fc9..9271bf6cd 100644--- a/fluxer_app/src/features/messaging/models/MessagingMessage.ts+++ b/fluxer_app/src/features/messaging/models/MessagingMessage.ts@@ -13,7 +13,6 @@ import {emojiEquals} from '@app/features/messaging/utils/ReactionUtils';import Relationships from '@app/features/relationship/state/Relationships';import * as ThemeUtils from '@app/features/theme/utils/ThemeUtils';import {User} from '@app/features/user/models/User';-import UserGuildSettings from '@app/features/user/state/UserGuildSettings';import Users from '@app/features/user/state/Users';import {LRUMap} from '@app/lib/list/ListLruMap';import {MessageFlags, MessageStates, MessageTypes} from '@fluxer/constants/src/ChannelConstants';@@ -560,15 +559,23 @@ export class Message {}}-export const messageMentionsCurrentUser = (message: WireMessage): boolean => {+interface MentionSuppression {+ suppressEveryone?: boolean;+ suppressRoles?: boolean;+}++export const messageMentionsCurrentUser = (+ message: WireMessage,+ {suppressEveryone = false, suppressRoles = false}: MentionSuppression = {},+): boolean => {const channel = Channels.getChannel(message.channel_id);if (!channel) return false;- if (message.mention_everyone && !UserGuildSettings.isEveryoneMentionSuppressed(channel.guildId ?? null)) return true;+ if (message.mention_everyone && !suppressEveryone) return true;if (message.mentions?.some((user) => user.id === Authentication.currentUserId)) {return true;}if (!channel.guildId) return false;- if (UserGuildSettings.isRoleMentionSuppressed(channel.guildId)) return false;+ if (suppressRoles) return false;const guild = Guilds.getGuild(channel.guildId);if (!guild) return false;const guildMember = GuildMembers.getMember(guild.id, Authentication.currentUserId);diff --git a/fluxer_app/src/features/notification/state/MentionFeed.ts b/fluxer_app/src/features/notification/state/MentionFeed.tsindex 8fb74096b..30a720beb 100644--- a/fluxer_app/src/features/notification/state/MentionFeed.ts+++ b/fluxer_app/src/features/notification/state/MentionFeed.ts@@ -11,6 +11,7 @@ import {} from '@app/features/notification/utils/MentionFeedFilters';import Relationships from '@app/features/relationship/state/Relationships';import {makeSyncedField} from '@app/features/user/state/SyncedField';+import UserGuildSettings from '@app/features/user/state/UserGuildSettings';import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';import {MAX_MESSAGES_PER_CHANNEL} from '@fluxer/constants/src/LimitConstants';import type {Channel as WireChannel} from '@fluxer/schema/src/domains/channel/ChannelSchemas';@@ -179,14 +180,19 @@ class MentionFeed {}handleMessageCreate(message: WireMessage): void {- if (!messageMentionsCurrentUser(message)) {+ const channel = Channels.getChannel(message.channel_id);+ if (!channel) return;+ const guildId = channel.guildId ?? null;+ const mentioned = messageMentionsCurrentUser(message, {+ suppressEveryone: UserGuildSettings.isEveryoneMentionSuppressed(guildId),+ suppressRoles: UserGuildSettings.isRoleMentionSuppressed(guildId),+ });+ if (!mentioned) {return;}if (Relationships.isBlocked(message.author.id)) {return;}- const channel = Channels.getChannel(message.channel_id);- if (!channel) return;if (!this.isMessageIncludedByFilters(message, channel)) {return;}