flyzto před 3 týdny
rodič
revize
7f9dddfb34
2 změnil soubory, kde provedl 12 přidání a 12 odebrání
  1. 1 1
      pinnacle/libs/getAccount.js
  2. 11 11
      pinnacle/main.js

+ 1 - 1
pinnacle/libs/getAccount.js

@@ -43,7 +43,7 @@ const loadGlobalDataFromCache = async () => {
     if (!data) {
       return;
     }
-    Object.keys(ACCOUNT_OPTIONS).forEach(key => {
+    Object.keys(ACCOUNT_OPTIONS)?.forEach(key => {
       if (key in data) {
         ACCOUNT_OPTIONS[key] = data[key];
       }

+ 11 - 11
pinnacle/main.js

@@ -168,7 +168,7 @@ const updateStraightFixtures = async () => {
     }
     if (update && update == 'full') {
       const gamesSet = new Set(games.map(game => game.id));
-      Object.keys(gamesMap).forEach(key => {
+      Object.keys(gamesMap)?.forEach(key => {
         if (!gamesSet.has(+key)) {
           delete gamesMap[key];
         }
@@ -223,8 +223,8 @@ const getStraightOdds = async () => {
 const updateStraightOdds = async () => {
   return getStraightOdds()
   .then(games => {
-    if (games.length) {
-      const { gamesMap } = GLOBAL_DATA;
+    if (games?.length) {
+      const { gamesMap={} } = GLOBAL_DATA;
       games.forEach(game => {
         const { id, periods, ...rest } = game;
         const localGame = gamesMap[id];
@@ -260,7 +260,7 @@ const getSpecialFixtures = async () => {
   .then(data => {
     const { leagues, last } = data;
     if (!last) {
-      return [];
+      return { specials: [], update: 'increment' };
     }
     GLOBAL_DATA.specialFixturesVersion = last;
     const specials = leagues?.map(league => {
@@ -320,7 +320,7 @@ const updateSpecialFixtures = async () => {
   .then(data => {
     const { specials, update } = data;
     if (specials?.length) {
-      const { gamesMap } = GLOBAL_DATA;
+      const { gamesMap={} } = GLOBAL_DATA;
       const gamesSpecialsMap = {};
       specials.forEach(special => {
         const { eventId } = special;
@@ -393,7 +393,7 @@ const updateSpecialsOdds = async () => {
   return getSpecialsOdds()
   .then(specials => {
     if (specials.length) {
-      const { gamesMap } = GLOBAL_DATA;
+      const { gamesMap={} } = GLOBAL_DATA;
       const contestants = Object.values(gamesMap)
       .filter(game => game.specials)
       .map(game => {
@@ -405,7 +405,7 @@ const updateSpecialsOdds = async () => {
         return contestants;
       }).flat(2);
       const contestantsMap = new Map(contestants);
-      const lines = specials.flatMap(special => special.contestantLines);
+      const lines = specials?.flatMap(special => special.contestantLines) ?? [];
       lines.forEach(line => {
         const { id, handicap, lineId, max, price } = line;
         const contestant = contestantsMap.get(id);
@@ -442,7 +442,7 @@ const updateInRunning = async () => {
     if (!games.length) {
       return;
     }
-    const { gamesMap } = GLOBAL_DATA;
+    const { gamesMap={} } = GLOBAL_DATA;
     games.forEach(game => {
       const { id, state, elapsed } = game;
       const localGame = gamesMap[id];
@@ -643,7 +643,7 @@ const parseGame = (game) => {
 
 
 const getGames = () => {
-  const { filtedGames, gamesMap } = GLOBAL_DATA;
+  const { filtedGames, gamesMap={} } = GLOBAL_DATA;
   const filtedGamesSet = new Set(filtedGames);
   const nowTime = Date.now();
   const gamesData = {};
@@ -687,7 +687,7 @@ const getGames = () => {
     }
 
     if (actived) {
-      parseGame(game).forEach(gameInfo => {
+      parseGame(game)?.forEach(gameInfo => {
         const { marketType, ...rest } = gameInfo;
         if (!gamesData[marketType]) {
           gamesData[marketType] = [];
@@ -791,7 +791,7 @@ const loadGlobalDataFromCache = async () => {
     if (!data) {
       return;
     }
-    Object.keys(GLOBAL_DATA).forEach(key => {
+    Object.keys(GLOBAL_DATA)?.forEach(key => {
       if (key in data) {
         GLOBAL_DATA[key] = data[key];
       }