1 export const compareCrew = (a, b) => {
2 return compareCrewConfirmed(a, b) || compareCrewChannel(a, b) || compareCrewName(a, b);
5 export const compareCrewChannel = (a, b) => {
6 const a_channel = (a && a.channel_id) || null;
7 const b_channel = (b && b.channel_id) || null;
8 if (a_channel === b_channel) return 0;
9 if (!a_channel) return -1;
10 if (!b_channel) return 1;
11 return a_channel - b_channel;
14 export const compareCrewConfirmed = (a, b) => {
15 const a_confirmed = !!(a && a.confirmed);
16 const b_confirmed = !!(b && b.confirmed);
17 if (a_confirmed === b_confirmed) {
20 return a_confirmed ? -1 : 1;
23 export const compareCrewName = (a, b) => {
24 return getName(a).localeCompare(getName(b));
27 export const getName = crew => {
29 if (crew.name_override) {
30 return crew.name_override;
33 return crew.user.nickname || crew.user.username;
38 export const getStreamLink = crew => {
39 if (crew.stream_override) {
40 return crew.stream_override;
42 if (crew.user && crew.user.stream_link) {
43 return crew.user.stream_link;