Skip to content

Commit 613ef7b

Browse files
committed
update hooks and prebuilt to support the possibility of joined_at being undefined
1 parent 8366da6 commit 613ef7b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/hooks/useParticipantIds.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,19 @@ export const useParticipantIds = (
9292
case 'user_id':
9393
case 'user_name':
9494
sortFn = (a, b) => {
95-
if (a[sort] < b[sort]) return -1;
96-
if (a[sort] > b[sort]) return 1;
95+
// joined_at can technically be undefined. so in that
96+
// case, sort whichever has a value first. though, it
97+
// should only be undefined in prejoin, when there are
98+
// no other participants to sort so... really this
99+
// shouldn't happen :)
100+
let aSort = a[sort];
101+
let bSort = b[sort];
102+
if (aSort !== undefined || bSort !== undefined) {
103+
if (aSort === undefined) return -1;
104+
if (bSort === undefined) return 1;
105+
if (aSort > bSort) return 1;
106+
if (aSort < bSort) return -1;
107+
}
97108
return 0;
98109
};
99110
break;

0 commit comments

Comments
 (0)