Skip to content

Commit 28dbb99

Browse files
agrawal-dgnprice
authored andcommitted
user [nfc]: Create selector 'getActiveUsersById'.
'getActiveUsersById' returns all users except those which have been deactivated as map with user ID as the key. This slector will be used in 'getUserIsActive',as a map offers a better performance than linear scans over arrays, and these values will also be cached. See #3339 for discussion.
1 parent 239c75c commit 28dbb99

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/users/userSelectors.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ export const getActiveUsersByEmail: Selector<Map<string, UserOrBot>> = createSel
161161
new Map([...users, ...crossRealmBots].map(user => [user.email, user])),
162162
);
163163

164+
/** Excludes deactivated users. See `getAllUsers` for discussion. */
165+
export const getActiveUsersById: Selector<Map<number, UserOrBot>> = createSelector(
166+
getUsers,
167+
getCrossRealmBots,
168+
(users = [], crossRealmBots = []) =>
169+
new Map([...users, ...crossRealmBots].map(user => [user.user_id, user])),
170+
);
171+
164172
/**
165173
* The user with the given user ID.
166174
*

0 commit comments

Comments
 (0)