|
@@ -79,15 +79,19 @@ const isEventAvailable = (event) => {
|
|
|
return startsTime >= Date.now() - 3 * 60 * 60 * 1000 && startsTime <= tomorrowEndTime;
|
|
return startsTime >= Date.now() - 3 * 60 * 60 * 1000 && startsTime <= tomorrowEndTime;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const sortEventsByStarts = (events) => {
|
|
|
|
|
+ return events.sort((a, b) => new Date(a.starts).getTime() - new Date(b.starts).getTime());
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export const getEventsByIds = (ids) => {
|
|
export const getEventsByIds = (ids) => {
|
|
|
const normalizedIds = normalizeIds(ids);
|
|
const normalizedIds = normalizeIds(ids);
|
|
|
const { gamesMap={} } = GLOBAL_DATA;
|
|
const { gamesMap={} } = GLOBAL_DATA;
|
|
|
|
|
|
|
|
if (!normalizedIds.length) {
|
|
if (!normalizedIds.length) {
|
|
|
- return Object.values(gamesMap).filter(isEventAvailable);
|
|
|
|
|
|
|
+ return sortEventsByStarts(Object.values(gamesMap).filter(isEventAvailable));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return normalizedIds.map(id => gamesMap[id]).filter(Boolean).filter(isEventAvailable);
|
|
|
|
|
|
|
+ return sortEventsByStarts(normalizedIds.map(id => gamesMap[id]).filter(Boolean).filter(isEventAvailable));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|