Skip to content

Commit aee6f49

Browse files
committed
fix comments
1 parent f70f546 commit aee6f49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/hooks/useParticipantIds.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,21 @@ export const useParticipantIds = ({
180180
)
181181
);
182182
const newCustomIds = participants
183+
// Make sure we don't accidentally try to filter/sort `null` participants
184+
// This can happen when a participant's id is already present in store
185+
// but the participant object is not stored, yet.
183186
.filter(Boolean)
187+
// Run custom filter, if it's a function. Otherwise don't filter any participants.
184188
.filter(typeof filter === 'function' ? filter : () => true)
189+
// Run custom sort, if it's a function. Otherwise don't sort.
185190
.sort(typeof sort === 'function' ? sort : () => 0)
191+
// Map back to session_id.
186192
.map((p) => p.session_id)
193+
// Filter any potential null/undefined ids.
194+
// This shouldn't really happen, but better safe than sorry.
187195
.filter(Boolean);
188196

197+
// Finally compare the new list of ids with the current one.
189198
if (customDeepEqual(customIds, newCustomIds)) return;
190199

191200
setCustomIds(newCustomIds);
@@ -194,7 +203,7 @@ export const useParticipantIds = ({
194203
);
195204

196205
/**
197-
* Initiliaze state.
206+
* Initialize state.
198207
*/
199208
useEffect(() => {
200209
maybeUpdateCustomIds();

0 commit comments

Comments
 (0)