From 36addbe7d4c14c5388d75ff7fea3d8c1897cc2d5 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Mon, 18 May 2026 21:33:15 +0200 Subject: [PATCH] fix(avatar-info): reactive Ignore/Unignore menu entry via useIsUserIgnored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Ignore <-> Unignore context-menu entry was driven by avatarInfo.isIgnored — a boolean captured by AvatarInfoUtilities once, at the time the avatar was clicked. If the user got ignored / unignored *while the popup was already open* (e.g. via the friends panel, or because a server push flipped the state), the menu kept showing the stale option and clicking it would no-op (or worse, double-ignore). Switch the menu items to read useIsUserIgnored(avatarInfo.name) — the reactive hook backed by IgnoredUsersManager.getIgnoredUsersSnapshot() + NitroEventType.IGNORED_USERS_UPDATED. Now the menu flips automatically the moment the ignore list changes, without re-opening. avatarInfo.isIgnored stays on the data object (other code paths still consume it) — only the user-facing menu toggle is now reactive. --- .../avatar-info/menu/AvatarInfoWidgetAvatarView.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetAvatarView.tsx b/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetAvatarView.tsx index 582b9a1..f5e362e 100644 --- a/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetAvatarView.tsx +++ b/src/components/room/widgets/avatar-info/menu/AvatarInfoWidgetAvatarView.tsx @@ -3,7 +3,7 @@ import { FC, useEffect, useMemo, useState } from 'react'; import { FaChevronLeft, FaChevronRight } from 'react-icons/fa'; import { AvatarInfoUser, DispatchUiEvent, GetOwnRoomObject, GetUserProfile, LocalizeText, MessengerFriend, ReportType, RoomWidgetUpdateChatInputContentEvent, SendMessageComposer } from '../../../../../api'; import { Flex } from '../../../../../common'; -import { useFriends, useHelp, useRoom, useSessionInfo, useWiredTools } from '../../../../../hooks'; +import { useFriends, useHelp, useIsUserIgnored, useRoom, useSessionInfo, useWiredTools } from '../../../../../hooks'; import { ContextMenuHeaderView } from '../../context-menu/ContextMenuHeaderView'; import { ContextMenuListItemView } from '../../context-menu/ContextMenuListItemView'; import { ContextMenuView } from '../../context-menu/ContextMenuView'; @@ -31,6 +31,10 @@ export const AvatarInfoWidgetAvatarView: FC = p const { roomSession = null, isHandItemBlocked = false } = useRoom(); const { userRespectRemaining = 0, respectUser = null } = useSessionInfo(); const { openInspectionForUser, showInspectButton } = useWiredTools(); + // Reactive: the menu auto-flips Ignore <-> Unignore if the state + // changes while the popup is open, instead of being frozen to the + // snapshot AvatarInfoUtilities took at click time. + const isIgnored = useIsUserIgnored(avatarInfo.name); const isShowGiveRights = useMemo(() => { @@ -231,11 +235,11 @@ export const AvatarInfoWidgetAvatarView: FC = p { LocalizeText('infostand.link.relationship') } } - { !avatarInfo.isIgnored && + { !isIgnored && processAction('ignore') }> { LocalizeText('infostand.button.ignore') } } - { avatarInfo.isIgnored && + { isIgnored && processAction('unignore') }> { LocalizeText('infostand.button.unignore') } }