From a3b4ed2f33a7b9404c04971edb5b59ee190d7dac Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 13 Dec 2024 17:30:14 +0000 Subject: [PATCH] Add some logging to `UserIdenitityWarning` We had some reports of misbehaviour here, so adding a bit of looging to try to track it down. --- src/components/views/rooms/UserIdentityWarning.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/views/rooms/UserIdentityWarning.tsx b/src/components/views/rooms/UserIdentityWarning.tsx index 564ab719875..dbb6d3d0499 100644 --- a/src/components/views/rooms/UserIdentityWarning.tsx +++ b/src/components/views/rooms/UserIdentityWarning.tsx @@ -103,12 +103,17 @@ export const UserIdentityWarning: React.FC = ({ room } if (currentPrompt && membersNeedingApproval.has(currentPrompt.userId)) return currentPrompt; if (membersNeedingApproval.size === 0) { + if (currentPrompt) { + // If we were previously showing a warning, log that we've stopped doing so. + logger.debug("UserIdentityWarning: no users left that need approval"); + } return undefined; } // We pick the user with the smallest user ID. const keys = Array.from(membersNeedingApproval.keys()).sort((a, b) => a.localeCompare(b)); const selection = membersNeedingApproval.get(keys[0]!); + logger.debug(`UserIdentityWarning: now warning about user ${selection?.userId}`); return selection; }); }, []); @@ -132,6 +137,9 @@ export const UserIdentityWarning: React.FC = ({ room } // initialising, and we want to start by displaying a warning // for the user with the smallest ID. if (initialisedRef.current === InitialisationStatus.Completed) { + logger.debug( + `UserIdentityWarning: user ${userId} now needs approval; approval-pending list now [${Array.from(membersNeedingApprovalRef.current.keys())}]`, + ); updateCurrentPrompt(); } }, @@ -173,6 +181,9 @@ export const UserIdentityWarning: React.FC = ({ room } const removeMemberNeedingApproval = useCallback( (userId: string): void => { membersNeedingApprovalRef.current.delete(userId); + logger.debug( + `UserIdentityWarning: user ${userId} no longer needs approval; approval-pending list now [${Array.from(membersNeedingApprovalRef.current.keys())}]`, + ); updateCurrentPrompt(); }, [updateCurrentPrompt], @@ -195,6 +206,9 @@ export const UserIdentityWarning: React.FC = ({ room } const members = await room.getEncryptionTargetMembers(); await addMembersWhoNeedApproval(members); + logger.info( + `Initialised UserIdentityWarning component for room ${room.roomId} with approval-pending list [${Array.from(membersNeedingApprovalRef.current.keys())}]`, + ); updateCurrentPrompt(); initialisedRef.current = InitialisationStatus.Completed; }, [crypto, room, addMembersWhoNeedApproval, updateCurrentPrompt]);