@everymatrix/casino-games-category-section 0.0.362 → 0.0.363

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-games-category-section",
3
- "version": "0.0.362",
3
+ "version": "0.0.363",
4
4
  "main": "dist/casino-games-category-section.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "154d1b620474e61bee3507cc52d40bfd33236024"
39
+ "gitHead": "c387eff5f038dffc7fde68f7e15e1ca719f4f209"
40
40
  }
@@ -97,6 +97,7 @@
97
97
  let hidden;
98
98
  let visibilityChange;
99
99
  let dataloaded;
100
+ let categoriesCache:Object = {};
100
101
 
101
102
  let favoriteGamesData:any = {
102
103
  items: [],
@@ -209,30 +210,28 @@
209
210
  }
210
211
  }
211
212
 
212
- const sessionData = JSON.parse(sessionStorage.getItem(categoryId));
213
+ if ( categoryId && Object.keys(categoriesCache).indexOf(categoryId) >= 0) {
214
+
215
+ resolve(categoriesCache[categoryId]);
213
216
 
214
- if(sessionData){
215
- isLoading = false;
216
-
217
- resolve(sessionData);
218
- } else {
217
+ } else {
219
218
  fetch(url)
220
- .then((res:any) => res.json())
221
- .then((categoryData:any) => {
222
- dataloaded = true
223
- hasErrors = false;
224
- maxTotal = categoryData.games.total;
225
-
226
- sessionStorage.setItem(categoryId, JSON.stringify(categoryData));
227
-
228
- resolve(categoryData);
229
- }, (err:any) => {
230
- hasErrors = true;
231
-
232
- console.error(err);
233
-
234
- reject(err);
235
- });
219
+ .then((res:any) => res.json())
220
+ .then((categoryData:any) => {
221
+ dataloaded = true
222
+ hasErrors = false;
223
+ maxTotal = categoryData.games.total;
224
+
225
+ categoriesCache[categoryId] = categoryData;
226
+
227
+ resolve(categoryData);
228
+ }, (err:any) => {
229
+ hasErrors = true;
230
+
231
+ console.error(err);
232
+
233
+ reject(err);
234
+ });
236
235
  }
237
236
  });
238
237
  }