You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-09-04 19:42:11 +03:00
More clarity on cache updating
This commit is contained in:
@@ -206,15 +206,19 @@ function _updateDisplayNameCache(roomState, userId, displayName) {
|
|||||||
var oldName = roomState._userIdsToDisplayNames[userId];
|
var oldName = roomState._userIdsToDisplayNames[userId];
|
||||||
delete roomState._userIdsToDisplayNames[userId];
|
delete roomState._userIdsToDisplayNames[userId];
|
||||||
if (oldName) {
|
if (oldName) {
|
||||||
var existing = roomState._displayNameToUserIds[oldName] || [];
|
// Remove the old name from the cache.
|
||||||
for (var i = 0; i < existing.length; i++) {
|
// We clobber the user_id > name lookup but the name -> [user_id] lookup
|
||||||
if (existing[i] === userId) {
|
// means we need to remove that user ID from that array rather than nuking
|
||||||
|
// the lot.
|
||||||
|
var existingUserIds = roomState._displayNameToUserIds[oldName] || [];
|
||||||
|
for (var i = 0; i < existingUserIds.length; i++) {
|
||||||
|
if (existingUserIds[i] === userId) {
|
||||||
// remove this user ID from this array
|
// remove this user ID from this array
|
||||||
existing.splice(i, 1);
|
existingUserIds.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
roomState._displayNameToUserIds[oldName] = existing;
|
roomState._displayNameToUserIds[oldName] = existingUserIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
roomState._userIdsToDisplayNames[userId] = displayName;
|
roomState._userIdsToDisplayNames[userId] = displayName;
|
||||||
|
Reference in New Issue
Block a user