@everymatrix/casino-categories-slider 0.0.167 → 0.0.171

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.
@@ -5292,7 +5292,7 @@
5292
5292
  const { console: console_1 } = globals;
5293
5293
  const file = "src/CasinoCategoriesSlider.svelte";
5294
5294
 
5295
- // (187:4) {:else}
5295
+ // (224:4) {:else}
5296
5296
  function create_else_block(ctx) {
5297
5297
  let div;
5298
5298
  let casino_slider;
@@ -5307,32 +5307,32 @@
5307
5307
  set_custom_element_data(casino_slider, "clientstylingurl", /*clientstylingurl*/ ctx[1]);
5308
5308
  set_custom_element_data(casino_slider, "containermaxwidth", /*containermaxwidth*/ ctx[2]);
5309
5309
  set_custom_element_data(casino_slider, "onclickeventname", "CategoryChange");
5310
- add_location(casino_slider, file, 188, 8, 6054);
5310
+ add_location(casino_slider, file, 225, 8, 7246);
5311
5311
  attr_dev(div, "class", "CasinoCategoriesContainer");
5312
- add_location(div, file, 187, 6, 6006);
5312
+ add_location(div, file, 224, 6, 7198);
5313
5313
  },
5314
5314
  m: function mount(target, anchor) {
5315
5315
  insert_dev(target, div, anchor);
5316
5316
  append_dev(div, casino_slider);
5317
5317
  },
5318
5318
  p: function update(ctx, dirty) {
5319
- if (dirty & /*numberOfFavoredGames*/ 128) {
5319
+ if (dirty[0] & /*numberOfFavoredGames*/ 128) {
5320
5320
  set_custom_element_data(casino_slider, "favoritesnumber", /*numberOfFavoredGames*/ ctx[7]);
5321
5321
  }
5322
5322
 
5323
- if (dirty & /*categories*/ 16) {
5323
+ if (dirty[0] & /*categories*/ 16) {
5324
5324
  set_custom_element_data(casino_slider, "sliderdata", /*categories*/ ctx[4]);
5325
5325
  }
5326
5326
 
5327
- if (dirty & /*clientstyling*/ 1) {
5327
+ if (dirty[0] & /*clientstyling*/ 1) {
5328
5328
  set_custom_element_data(casino_slider, "clientstyling", /*clientstyling*/ ctx[0]);
5329
5329
  }
5330
5330
 
5331
- if (dirty & /*clientstylingurl*/ 2) {
5331
+ if (dirty[0] & /*clientstylingurl*/ 2) {
5332
5332
  set_custom_element_data(casino_slider, "clientstylingurl", /*clientstylingurl*/ ctx[1]);
5333
5333
  }
5334
5334
 
5335
- if (dirty & /*containermaxwidth*/ 4) {
5335
+ if (dirty[0] & /*containermaxwidth*/ 4) {
5336
5336
  set_custom_element_data(casino_slider, "containermaxwidth", /*containermaxwidth*/ ctx[2]);
5337
5337
  }
5338
5338
  },
@@ -5345,14 +5345,14 @@
5345
5345
  block,
5346
5346
  id: create_else_block.name,
5347
5347
  type: "else",
5348
- source: "(187:4) {:else}",
5348
+ source: "(224:4) {:else}",
5349
5349
  ctx
5350
5350
  });
5351
5351
 
5352
5352
  return block;
5353
5353
  }
5354
5354
 
5355
- // (185:4) {#if hasErrors}
5355
+ // (222:4) {#if hasErrors}
5356
5356
  function create_if_block_1(ctx) {
5357
5357
  let p;
5358
5358
 
@@ -5361,7 +5361,7 @@
5361
5361
  p = element("p");
5362
5362
  p.textContent = "500 Error - Internal Server Error.";
5363
5363
  attr_dev(p, "class", "SearchLoading");
5364
- add_location(p, file, 185, 6, 5924);
5364
+ add_location(p, file, 222, 6, 7116);
5365
5365
  },
5366
5366
  m: function mount(target, anchor) {
5367
5367
  insert_dev(target, p, anchor);
@@ -5376,14 +5376,14 @@
5376
5376
  block,
5377
5377
  id: create_if_block_1.name,
5378
5378
  type: "if",
5379
- source: "(185:4) {#if hasErrors}",
5379
+ source: "(222:4) {#if hasErrors}",
5380
5380
  ctx
5381
5381
  });
5382
5382
 
5383
5383
  return block;
5384
5384
  }
5385
5385
 
5386
- // (182:2) {#if isLoading}
5386
+ // (219:2) {#if isLoading}
5387
5387
  function create_if_block(ctx) {
5388
5388
  let p;
5389
5389
 
@@ -5391,7 +5391,7 @@
5391
5391
  c: function create() {
5392
5392
  p = element("p");
5393
5393
  p.textContent = "Please wait ...";
5394
- add_location(p, file, 182, 4, 5865);
5394
+ add_location(p, file, 219, 4, 7057);
5395
5395
  },
5396
5396
  m: function mount(target, anchor) {
5397
5397
  insert_dev(target, p, anchor);
@@ -5406,7 +5406,7 @@
5406
5406
  block,
5407
5407
  id: create_if_block.name,
5408
5408
  type: "if",
5409
- source: "(182:2) {#if isLoading}",
5409
+ source: "(219:2) {#if isLoading}",
5410
5410
  ctx
5411
5411
  });
5412
5412
 
@@ -5430,7 +5430,7 @@
5430
5430
  div = element("div");
5431
5431
  if_block.c();
5432
5432
  this.c = noop$1;
5433
- add_location(div, file, 180, 0, 5802);
5433
+ add_location(div, file, 217, 0, 6994);
5434
5434
  },
5435
5435
  l: function claim(nodes) {
5436
5436
  throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -5438,9 +5438,9 @@
5438
5438
  m: function mount(target, anchor) {
5439
5439
  insert_dev(target, div, anchor);
5440
5440
  if_block.m(div, null);
5441
- /*div_binding*/ ctx[14](div);
5441
+ /*div_binding*/ ctx[18](div);
5442
5442
  },
5443
- p: function update(ctx, [dirty]) {
5443
+ p: function update(ctx, dirty) {
5444
5444
  if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
5445
5445
  if_block.p(ctx, dirty);
5446
5446
  } else {
@@ -5458,7 +5458,7 @@
5458
5458
  d: function destroy(detaching) {
5459
5459
  if (detaching) detach_dev(div);
5460
5460
  if_block.d();
5461
- /*div_binding*/ ctx[14](null);
5461
+ /*div_binding*/ ctx[18](null);
5462
5462
  }
5463
5463
  };
5464
5464
 
@@ -5480,6 +5480,7 @@
5480
5480
  let { endpoint = "" } = $$props;
5481
5481
  let { datasource = "" } = $$props;
5482
5482
  let { lang = "" } = $$props; // Language
5483
+ let { userid = "" } = $$props;
5483
5484
  let { session = "" } = $$props; // Value for sessionID
5484
5485
  let { mostplayed = "" } = $$props; // True - add MostPlayed category in slider
5485
5486
  let { favorites = "" } = $$props; // True - add Favorites category in slider
@@ -5502,6 +5503,9 @@
5502
5503
  let numberOfFavoredGames;
5503
5504
  let favoritesAdded = false;
5504
5505
  let mostPlayedAdded = false;
5506
+ let favoritesLoaded = false;
5507
+ let mostPlayedLoaded = false;
5508
+ let categoriesLoaded = false;
5505
5509
 
5506
5510
  const messageHandler = e => {
5507
5511
  if (e.data) {
@@ -5532,6 +5536,36 @@
5532
5536
  }
5533
5537
  };
5534
5538
 
5539
+ const getMostPlayedGames = () => {
5540
+ let url = new URL(`${endpoint}/player/${userid}/games/most-played`);
5541
+ let device = getDevice(userAgent);
5542
+
5543
+ if (device) {
5544
+ if (device === "PC") {
5545
+ url.searchParams.append("device", "Desktop");
5546
+ } else {
5547
+ url.searchParams.append("device", "Mobile");
5548
+ }
5549
+ } else {
5550
+ url.searchParams.append("device", "All");
5551
+ }
5552
+
5553
+ url.searchParams.append("rounds", "50");
5554
+
5555
+ return new Promise((resolve, reject) => {
5556
+ fetch(url.href).then(res => res.json()).then(data => {
5557
+ if (data.count == 0) {
5558
+ resolve(false);
5559
+ }
5560
+
5561
+ resolve(true);
5562
+ }).catch(err => {
5563
+ console.error("err", err);
5564
+ reject(false);
5565
+ });
5566
+ });
5567
+ };
5568
+
5535
5569
  const addFavoritesCategory = () => {
5536
5570
  if (favoritesAdded == false && favorites == "true") {
5537
5571
  categories.splice(1, 0, {
@@ -5543,22 +5577,24 @@
5543
5577
  }
5544
5578
 
5545
5579
  favoritesAdded = true;
5546
- $$invalidate(3, isLoading = false);
5580
+ $$invalidate(15, favoritesLoaded = true);
5547
5581
  };
5548
5582
 
5549
5583
  const addMostPlayedCategory = () => {
5550
- if (mostPlayedAdded == false && mostplayed == "true") {
5551
- categories.splice(1, 0, {
5552
- id: "MOSTPLAYED",
5553
- name: "Most Played",
5554
- href: "",
5555
- games: [],
5556
- triggerFetch: false
5557
- });
5558
- }
5584
+ getMostPlayedGames().then(display => {
5585
+ if (mostPlayedAdded == false && mostplayed == "true" && display) {
5586
+ categories.splice(2, 0, {
5587
+ id: "MOSTPLAYED",
5588
+ name: "Most Played",
5589
+ href: "",
5590
+ games: [],
5591
+ triggerFetch: false
5592
+ });
5593
+ }
5559
5594
 
5560
- mostPlayedAdded = true;
5561
- $$invalidate(3, isLoading = false);
5595
+ mostPlayedAdded = true;
5596
+ $$invalidate(16, mostPlayedLoaded = true);
5597
+ });
5562
5598
  };
5563
5599
 
5564
5600
  const checkAttrs = () => {
@@ -5586,14 +5622,15 @@
5586
5622
  return hasErrors;
5587
5623
  };
5588
5624
 
5625
+ const checkIfLoaded = () => {
5626
+ $$invalidate(3, isLoading = !favoritesLoaded && !mostPlayedLoaded && !categoriesLoaded);
5627
+ };
5628
+
5589
5629
  const initialLoad = () => {
5590
5630
  if (!checkAttrs()) {
5591
- $$invalidate(3, isLoading = true);
5592
5631
  let url = new URL(`${endpoint}/casino/groups/${datasource}`);
5593
5632
  url.searchParams.append("datasource", datasource);
5594
-
5595
- // @TODO add back getDevice method
5596
- // url.searchParams.append('platform', getDevice(userAgent));
5633
+ url.searchParams.append("platform", getDevice(userAgent));
5597
5634
  url.searchParams.append("language", lang);
5598
5635
 
5599
5636
  fetch(url).then(res => res.json()).then(
@@ -5613,8 +5650,8 @@
5613
5650
  games: []
5614
5651
  });
5615
5652
 
5653
+ $$invalidate(17, categoriesLoaded = true);
5616
5654
  window.postMessage({ type: "CategoriesLoadedForSlider" }, window.location.href);
5617
- $$invalidate(3, isLoading = false);
5618
5655
  },
5619
5656
  err => {
5620
5657
  $$invalidate(5, hasErrors = true);
@@ -5674,6 +5711,7 @@
5674
5711
  "endpoint",
5675
5712
  "datasource",
5676
5713
  "lang",
5714
+ "userid",
5677
5715
  "session",
5678
5716
  "mostplayed",
5679
5717
  "favorites",
@@ -5697,9 +5735,10 @@
5697
5735
  if ("endpoint" in $$props) $$invalidate(8, endpoint = $$props.endpoint);
5698
5736
  if ("datasource" in $$props) $$invalidate(9, datasource = $$props.datasource);
5699
5737
  if ("lang" in $$props) $$invalidate(10, lang = $$props.lang);
5700
- if ("session" in $$props) $$invalidate(11, session = $$props.session);
5701
- if ("mostplayed" in $$props) $$invalidate(12, mostplayed = $$props.mostplayed);
5702
- if ("favorites" in $$props) $$invalidate(13, favorites = $$props.favorites);
5738
+ if ("userid" in $$props) $$invalidate(11, userid = $$props.userid);
5739
+ if ("session" in $$props) $$invalidate(12, session = $$props.session);
5740
+ if ("mostplayed" in $$props) $$invalidate(13, mostplayed = $$props.mostplayed);
5741
+ if ("favorites" in $$props) $$invalidate(14, favorites = $$props.favorites);
5703
5742
  if ("clientstyling" in $$props) $$invalidate(0, clientstyling = $$props.clientstyling);
5704
5743
  if ("clientstylingurl" in $$props) $$invalidate(1, clientstylingurl = $$props.clientstylingurl);
5705
5744
  if ("containermaxwidth" in $$props) $$invalidate(2, containermaxwidth = $$props.containermaxwidth);
@@ -5712,6 +5751,7 @@
5712
5751
  endpoint,
5713
5752
  datasource,
5714
5753
  lang,
5754
+ userid,
5715
5755
  session,
5716
5756
  mostplayed,
5717
5757
  favorites,
@@ -5731,10 +5771,15 @@
5731
5771
  numberOfFavoredGames,
5732
5772
  favoritesAdded,
5733
5773
  mostPlayedAdded,
5774
+ favoritesLoaded,
5775
+ mostPlayedLoaded,
5776
+ categoriesLoaded,
5734
5777
  messageHandler,
5778
+ getMostPlayedGames,
5735
5779
  addFavoritesCategory,
5736
5780
  addMostPlayedCategory,
5737
5781
  checkAttrs,
5782
+ checkIfLoaded,
5738
5783
  initialLoad,
5739
5784
  setSession,
5740
5785
  setClientStyling,
@@ -5745,9 +5790,10 @@
5745
5790
  if ("endpoint" in $$props) $$invalidate(8, endpoint = $$props.endpoint);
5746
5791
  if ("datasource" in $$props) $$invalidate(9, datasource = $$props.datasource);
5747
5792
  if ("lang" in $$props) $$invalidate(10, lang = $$props.lang);
5748
- if ("session" in $$props) $$invalidate(11, session = $$props.session);
5749
- if ("mostplayed" in $$props) $$invalidate(12, mostplayed = $$props.mostplayed);
5750
- if ("favorites" in $$props) $$invalidate(13, favorites = $$props.favorites);
5793
+ if ("userid" in $$props) $$invalidate(11, userid = $$props.userid);
5794
+ if ("session" in $$props) $$invalidate(12, session = $$props.session);
5795
+ if ("mostplayed" in $$props) $$invalidate(13, mostplayed = $$props.mostplayed);
5796
+ if ("favorites" in $$props) $$invalidate(14, favorites = $$props.favorites);
5751
5797
  if ("clientstyling" in $$props) $$invalidate(0, clientstyling = $$props.clientstyling);
5752
5798
  if ("clientstylingurl" in $$props) $$invalidate(1, clientstylingurl = $$props.clientstylingurl);
5753
5799
  if ("containermaxwidth" in $$props) $$invalidate(2, containermaxwidth = $$props.containermaxwidth);
@@ -5764,6 +5810,9 @@
5764
5810
  if ("numberOfFavoredGames" in $$props) $$invalidate(7, numberOfFavoredGames = $$props.numberOfFavoredGames);
5765
5811
  if ("favoritesAdded" in $$props) favoritesAdded = $$props.favoritesAdded;
5766
5812
  if ("mostPlayedAdded" in $$props) mostPlayedAdded = $$props.mostPlayedAdded;
5813
+ if ("favoritesLoaded" in $$props) $$invalidate(15, favoritesLoaded = $$props.favoritesLoaded);
5814
+ if ("mostPlayedLoaded" in $$props) $$invalidate(16, mostPlayedLoaded = $$props.mostPlayedLoaded);
5815
+ if ("categoriesLoaded" in $$props) $$invalidate(17, categoriesLoaded = $$props.categoriesLoaded);
5767
5816
  };
5768
5817
 
5769
5818
  if ($$props && "$$inject" in $$props) {
@@ -5771,27 +5820,31 @@
5771
5820
  }
5772
5821
 
5773
5822
  $$self.$$.update = () => {
5774
- if ($$self.$$.dirty & /*endpoint, datasource, lang*/ 1792) {
5823
+ if ($$self.$$.dirty[0] & /*favoritesLoaded, mostPlayedLoaded, categoriesLoaded*/ 229376) {
5824
+ favoritesLoaded && mostPlayedLoaded && categoriesLoaded && checkIfLoaded();
5825
+ }
5826
+
5827
+ if ($$self.$$.dirty[0] & /*endpoint, datasource, lang*/ 1792) {
5775
5828
  endpoint && datasource && lang && initialLoad();
5776
5829
  }
5777
5830
 
5778
- if ($$self.$$.dirty & /*session, endpoint*/ 2304) {
5831
+ if ($$self.$$.dirty[0] & /*session, endpoint*/ 4352) {
5779
5832
  session && endpoint && setSession();
5780
5833
  }
5781
5834
 
5782
- if ($$self.$$.dirty & /*session, favorites*/ 10240) {
5835
+ if ($$self.$$.dirty[0] & /*session, favorites*/ 20480) {
5783
5836
  session && favorites && addFavoritesCategory();
5784
5837
  }
5785
5838
 
5786
- if ($$self.$$.dirty & /*session, mostplayed*/ 6144) {
5787
- session && mostplayed && addMostPlayedCategory();
5839
+ if ($$self.$$.dirty[0] & /*session, userid, mostplayed*/ 14336) {
5840
+ session && userid && mostplayed && addMostPlayedCategory();
5788
5841
  }
5789
5842
 
5790
- if ($$self.$$.dirty & /*clientstyling*/ 1) {
5843
+ if ($$self.$$.dirty[0] & /*clientstyling*/ 1) {
5791
5844
  clientstyling && setClientStyling();
5792
5845
  }
5793
5846
 
5794
- if ($$self.$$.dirty & /*clientstylingurl*/ 2) {
5847
+ if ($$self.$$.dirty[0] & /*clientstylingurl*/ 2) {
5795
5848
  clientstylingurl && setClientStylingURL();
5796
5849
  }
5797
5850
  };
@@ -5810,9 +5863,13 @@
5810
5863
  endpoint,
5811
5864
  datasource,
5812
5865
  lang,
5866
+ userid,
5813
5867
  session,
5814
5868
  mostplayed,
5815
5869
  favorites,
5870
+ favoritesLoaded,
5871
+ mostPlayedLoaded,
5872
+ categoriesLoaded,
5816
5873
  div_binding
5817
5874
  ];
5818
5875
  }
@@ -5836,13 +5893,15 @@
5836
5893
  endpoint: 8,
5837
5894
  datasource: 9,
5838
5895
  lang: 10,
5839
- session: 11,
5840
- mostplayed: 12,
5841
- favorites: 13,
5896
+ userid: 11,
5897
+ session: 12,
5898
+ mostplayed: 13,
5899
+ favorites: 14,
5842
5900
  clientstyling: 0,
5843
5901
  clientstylingurl: 1,
5844
5902
  containermaxwidth: 2
5845
- }
5903
+ },
5904
+ [-1, -1]
5846
5905
  );
5847
5906
 
5848
5907
  if (options) {
@@ -5862,6 +5921,7 @@
5862
5921
  "endpoint",
5863
5922
  "datasource",
5864
5923
  "lang",
5924
+ "userid",
5865
5925
  "session",
5866
5926
  "mostplayed",
5867
5927
  "favorites",
@@ -5898,17 +5958,26 @@
5898
5958
  flush();
5899
5959
  }
5900
5960
 
5901
- get session() {
5961
+ get userid() {
5902
5962
  return this.$$.ctx[11];
5903
5963
  }
5904
5964
 
5965
+ set userid(userid) {
5966
+ this.$set({ userid });
5967
+ flush();
5968
+ }
5969
+
5970
+ get session() {
5971
+ return this.$$.ctx[12];
5972
+ }
5973
+
5905
5974
  set session(session) {
5906
5975
  this.$set({ session });
5907
5976
  flush();
5908
5977
  }
5909
5978
 
5910
5979
  get mostplayed() {
5911
- return this.$$.ctx[12];
5980
+ return this.$$.ctx[13];
5912
5981
  }
5913
5982
 
5914
5983
  set mostplayed(mostplayed) {
@@ -5917,7 +5986,7 @@
5917
5986
  }
5918
5987
 
5919
5988
  get favorites() {
5920
- return this.$$.ctx[13];
5989
+ return this.$$.ctx[14];
5921
5990
  }
5922
5991
 
5923
5992
  set favorites(favorites) {