]> git.localhorst.tv Git - alttp.git/blob - resources/js/helpers/Crew.js
some discord bot stuff
[alttp.git] / resources / js / helpers / Crew.js
1 export const compareCrew = (a, b) => {
2         const a_confirmed = !!(a && a.confirmed);
3         const b_confirmed = !!(b && b.confirmed);
4         if (a_confirmed === b_confirmed) {
5                 return getName(a).localeCompare(getName(b));
6         }
7         return a_confirmed ? -1 : 1;
8 };
9
10 export const getName = crew => {
11         if (!crew) return '';
12         if (crew.name_override) {
13                 return crew.name_override;
14         }
15         if (crew.user) {
16                 return crew.user.nickname || crew.user.username;
17         }
18         return '';
19 };
20
21 export const getStreamLink = crew => {
22         if (crew.stream_override) {
23                 return crew.stream_override;
24         }
25         if (crew.user && crew.user.stream_link) {
26                 return crew.user.stream_link;
27         }
28         return '';
29 };
30