Skip to content

Commit bea1b8e

Browse files
authored
Add some logging to UserIdenitityWarning (#28734)
We had some reports of misbehaviour here, so adding a bit of looging to try to track it down.
1 parent d5db16c commit bea1b8e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/components/views/rooms/UserIdentityWarning.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,17 @@ export const UserIdentityWarning: React.FC<UserIdentityWarningProps> = ({ room }
103103
if (currentPrompt && membersNeedingApproval.has(currentPrompt.userId)) return currentPrompt;
104104

105105
if (membersNeedingApproval.size === 0) {
106+
if (currentPrompt) {
107+
// If we were previously showing a warning, log that we've stopped doing so.
108+
logger.debug("UserIdentityWarning: no users left that need approval");
109+
}
106110
return undefined;
107111
}
108112

109113
// We pick the user with the smallest user ID.
110114
const keys = Array.from(membersNeedingApproval.keys()).sort((a, b) => a.localeCompare(b));
111115
const selection = membersNeedingApproval.get(keys[0]!);
116+
logger.debug(`UserIdentityWarning: now warning about user ${selection?.userId}`);
112117
return selection;
113118
});
114119
}, []);
@@ -132,6 +137,9 @@ export const UserIdentityWarning: React.FC<UserIdentityWarningProps> = ({ room }
132137
// initialising, and we want to start by displaying a warning
133138
// for the user with the smallest ID.
134139
if (initialisedRef.current === InitialisationStatus.Completed) {
140+
logger.debug(
141+
`UserIdentityWarning: user ${userId} now needs approval; approval-pending list now [${Array.from(membersNeedingApprovalRef.current.keys())}]`,
142+
);
135143
updateCurrentPrompt();
136144
}
137145
},
@@ -173,6 +181,9 @@ export const UserIdentityWarning: React.FC<UserIdentityWarningProps> = ({ room }
173181
const removeMemberNeedingApproval = useCallback(
174182
(userId: string): void => {
175183
membersNeedingApprovalRef.current.delete(userId);
184+
logger.debug(
185+
`UserIdentityWarning: user ${userId} no longer needs approval; approval-pending list now [${Array.from(membersNeedingApprovalRef.current.keys())}]`,
186+
);
176187
updateCurrentPrompt();
177188
},
178189
[updateCurrentPrompt],
@@ -195,6 +206,9 @@ export const UserIdentityWarning: React.FC<UserIdentityWarningProps> = ({ room }
195206
const members = await room.getEncryptionTargetMembers();
196207
await addMembersWhoNeedApproval(members);
197208

209+
logger.info(
210+
`Initialised UserIdentityWarning component for room ${room.roomId} with approval-pending list [${Array.from(membersNeedingApprovalRef.current.keys())}]`,
211+
);
198212
updateCurrentPrompt();
199213
initialisedRef.current = InitialisationStatus.Completed;
200214
}, [crypto, room, addMembersWhoNeedApproval, updateCurrentPrompt]);

0 commit comments

Comments
 (0)