1 export const hasActiveGuessing = channel =>
2 channel && channel.guessing_start;
4 export const isAcceptingGuesses = channel =>
5 channel && channel.guessing_start && !channel.guessing_end;
7 export const patchGuess = (guesses, guess) =>
8 [guess, ...(guesses || []).filter(g => g.uid !== guess.uid)];
10 export const patchWinner = (winners, winner) =>
11 [winner, ...(winners || []).filter(w => w.uid !== winner.uid)];
13 export const compareLive = (a, b) => {
14 const a_live = a && a.twitch_live;
15 const b_live = b && b.twitch_live;
28 export const compareName = (a, b) => {
29 const a_name = (a && (a.short_name || a.title)) || '';
30 const b_name = (b && (b.short_name || b.title)) || '';
31 return a_name.localeCompare(b_name);
34 export const compareTitle = (a, b) => {
35 const a_title = (a && a.title) || '';
36 const b_title = (b && b.title) || '';
37 return a_title.localeCompare(b_title);
40 export const compareViewers = (a, b) => {
41 const a_viewers = (a && a.twitch_live && a.twitch_viewers) || 0;
42 const b_viewers = (b && b.twitch_live && b.twitch_viewers) || 0;
43 return b_viewers - a_viewers;
46 export const compareHorstieLog = (a, b) => {
47 const live = compareLive(a, b);
48 if (live) return live;
49 const viewers = compareViewers(a, b);
50 if (viewers) return viewers;
51 return compareName(a, b);