@everymatrix/casino-categories-slider 0.0.169 → 0.0.173

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.
@@ -122,6 +122,10 @@
122
122
  resolved_promise.then(flush);
123
123
  }
124
124
  }
125
+ function tick() {
126
+ schedule_update();
127
+ return resolved_promise;
128
+ }
125
129
  function add_render_callback(fn) {
126
130
  render_callbacks.push(fn);
127
131
  }
@@ -5292,7 +5296,7 @@
5292
5296
  const { console: console_1 } = globals;
5293
5297
  const file = "src/CasinoCategoriesSlider.svelte";
5294
5298
 
5295
- // (187:4) {:else}
5299
+ // (224:4) {:else}
5296
5300
  function create_else_block(ctx) {
5297
5301
  let div;
5298
5302
  let casino_slider;
@@ -5307,32 +5311,32 @@
5307
5311
  set_custom_element_data(casino_slider, "clientstylingurl", /*clientstylingurl*/ ctx[1]);
5308
5312
  set_custom_element_data(casino_slider, "containermaxwidth", /*containermaxwidth*/ ctx[2]);
5309
5313
  set_custom_element_data(casino_slider, "onclickeventname", "CategoryChange");
5310
- add_location(casino_slider, file, 188, 8, 6054);
5314
+ add_location(casino_slider, file, 225, 8, 7254);
5311
5315
  attr_dev(div, "class", "CasinoCategoriesContainer");
5312
- add_location(div, file, 187, 6, 6006);
5316
+ add_location(div, file, 224, 6, 7206);
5313
5317
  },
5314
5318
  m: function mount(target, anchor) {
5315
5319
  insert_dev(target, div, anchor);
5316
5320
  append_dev(div, casino_slider);
5317
5321
  },
5318
5322
  p: function update(ctx, dirty) {
5319
- if (dirty & /*numberOfFavoredGames*/ 128) {
5323
+ if (dirty[0] & /*numberOfFavoredGames*/ 128) {
5320
5324
  set_custom_element_data(casino_slider, "favoritesnumber", /*numberOfFavoredGames*/ ctx[7]);
5321
5325
  }
5322
5326
 
5323
- if (dirty & /*categories*/ 16) {
5327
+ if (dirty[0] & /*categories*/ 16) {
5324
5328
  set_custom_element_data(casino_slider, "sliderdata", /*categories*/ ctx[4]);
5325
5329
  }
5326
5330
 
5327
- if (dirty & /*clientstyling*/ 1) {
5331
+ if (dirty[0] & /*clientstyling*/ 1) {
5328
5332
  set_custom_element_data(casino_slider, "clientstyling", /*clientstyling*/ ctx[0]);
5329
5333
  }
5330
5334
 
5331
- if (dirty & /*clientstylingurl*/ 2) {
5335
+ if (dirty[0] & /*clientstylingurl*/ 2) {
5332
5336
  set_custom_element_data(casino_slider, "clientstylingurl", /*clientstylingurl*/ ctx[1]);
5333
5337
  }
5334
5338
 
5335
- if (dirty & /*containermaxwidth*/ 4) {
5339
+ if (dirty[0] & /*containermaxwidth*/ 4) {
5336
5340
  set_custom_element_data(casino_slider, "containermaxwidth", /*containermaxwidth*/ ctx[2]);
5337
5341
  }
5338
5342
  },
@@ -5345,14 +5349,14 @@
5345
5349
  block,
5346
5350
  id: create_else_block.name,
5347
5351
  type: "else",
5348
- source: "(187:4) {:else}",
5352
+ source: "(224:4) {:else}",
5349
5353
  ctx
5350
5354
  });
5351
5355
 
5352
5356
  return block;
5353
5357
  }
5354
5358
 
5355
- // (185:4) {#if hasErrors}
5359
+ // (222:4) {#if hasErrors}
5356
5360
  function create_if_block_1(ctx) {
5357
5361
  let p;
5358
5362
 
@@ -5361,7 +5365,7 @@
5361
5365
  p = element("p");
5362
5366
  p.textContent = "500 Error - Internal Server Error.";
5363
5367
  attr_dev(p, "class", "SearchLoading");
5364
- add_location(p, file, 185, 6, 5924);
5368
+ add_location(p, file, 222, 6, 7124);
5365
5369
  },
5366
5370
  m: function mount(target, anchor) {
5367
5371
  insert_dev(target, p, anchor);
@@ -5376,14 +5380,14 @@
5376
5380
  block,
5377
5381
  id: create_if_block_1.name,
5378
5382
  type: "if",
5379
- source: "(185:4) {#if hasErrors}",
5383
+ source: "(222:4) {#if hasErrors}",
5380
5384
  ctx
5381
5385
  });
5382
5386
 
5383
5387
  return block;
5384
5388
  }
5385
5389
 
5386
- // (182:2) {#if isLoading}
5390
+ // (219:2) {#if isLoading || isLoadingMostPlayed}
5387
5391
  function create_if_block(ctx) {
5388
5392
  let p;
5389
5393
 
@@ -5391,7 +5395,7 @@
5391
5395
  c: function create() {
5392
5396
  p = element("p");
5393
5397
  p.textContent = "Please wait ...";
5394
- add_location(p, file, 182, 4, 5865);
5398
+ add_location(p, file, 219, 4, 7065);
5395
5399
  },
5396
5400
  m: function mount(target, anchor) {
5397
5401
  insert_dev(target, p, anchor);
@@ -5406,7 +5410,7 @@
5406
5410
  block,
5407
5411
  id: create_if_block.name,
5408
5412
  type: "if",
5409
- source: "(182:2) {#if isLoading}",
5413
+ source: "(219:2) {#if isLoading || isLoadingMostPlayed}",
5410
5414
  ctx
5411
5415
  });
5412
5416
 
@@ -5417,7 +5421,7 @@
5417
5421
  let div;
5418
5422
 
5419
5423
  function select_block_type(ctx, dirty) {
5420
- if (/*isLoading*/ ctx[3]) return create_if_block;
5424
+ if (/*isLoading*/ ctx[3] || /*isLoadingMostPlayed*/ ctx[8]) return create_if_block;
5421
5425
  if (/*hasErrors*/ ctx[5]) return create_if_block_1;
5422
5426
  return create_else_block;
5423
5427
  }
@@ -5430,7 +5434,7 @@
5430
5434
  div = element("div");
5431
5435
  if_block.c();
5432
5436
  this.c = noop$1;
5433
- add_location(div, file, 180, 0, 5802);
5437
+ add_location(div, file, 217, 0, 6979);
5434
5438
  },
5435
5439
  l: function claim(nodes) {
5436
5440
  throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -5438,9 +5442,9 @@
5438
5442
  m: function mount(target, anchor) {
5439
5443
  insert_dev(target, div, anchor);
5440
5444
  if_block.m(div, null);
5441
- /*div_binding*/ ctx[14](div);
5445
+ /*div_binding*/ ctx[16](div);
5442
5446
  },
5443
- p: function update(ctx, [dirty]) {
5447
+ p: function update(ctx, dirty) {
5444
5448
  if (current_block_type === (current_block_type = select_block_type(ctx)) && if_block) {
5445
5449
  if_block.p(ctx, dirty);
5446
5450
  } else {
@@ -5458,7 +5462,7 @@
5458
5462
  d: function destroy(detaching) {
5459
5463
  if (detaching) detach_dev(div);
5460
5464
  if_block.d();
5461
- /*div_binding*/ ctx[14](null);
5465
+ /*div_binding*/ ctx[16](null);
5462
5466
  }
5463
5467
  };
5464
5468
 
@@ -5480,6 +5484,7 @@
5480
5484
  let { endpoint = "" } = $$props;
5481
5485
  let { datasource = "" } = $$props;
5482
5486
  let { lang = "" } = $$props; // Language
5487
+ let { userid = "" } = $$props;
5483
5488
  let { session = "" } = $$props; // Value for sessionID
5484
5489
  let { mostplayed = "" } = $$props; // True - add MostPlayed category in slider
5485
5490
  let { favorites = "" } = $$props; // True - add Favorites category in slider
@@ -5502,6 +5507,9 @@
5502
5507
  let numberOfFavoredGames;
5503
5508
  let favoritesAdded = false;
5504
5509
  let mostPlayedAdded = false;
5510
+ let favoritesLoaded = false;
5511
+ let mostPlayedLoaded = false;
5512
+ let categoriesLoaded = false;
5505
5513
 
5506
5514
  const messageHandler = e => {
5507
5515
  if (e.data) {
@@ -5527,11 +5535,40 @@
5527
5535
  isLoggedIn = true;
5528
5536
  }
5529
5537
  break;
5530
- } // sessionID = session;
5531
- // playerID = userID;
5538
+ }
5532
5539
  }
5533
5540
  };
5534
5541
 
5542
+ const getMostPlayedGames = () => {
5543
+ let url = new URL(`${endpoint}/player/${userid}/games/most-played`);
5544
+ let device = getDevice(userAgent);
5545
+
5546
+ if (device) {
5547
+ if (device === "PC") {
5548
+ url.searchParams.append("device", "Desktop");
5549
+ } else {
5550
+ url.searchParams.append("device", "Mobile");
5551
+ }
5552
+ } else {
5553
+ url.searchParams.append("device", "All");
5554
+ }
5555
+
5556
+ url.searchParams.append("rounds", "50");
5557
+
5558
+ return new Promise((resolve, reject) => {
5559
+ fetch(url.href).then(res => res.json()).then(data => {
5560
+ if (data.count == 0) {
5561
+ resolve(false);
5562
+ }
5563
+
5564
+ resolve(true);
5565
+ }).catch(err => {
5566
+ console.error("err", err);
5567
+ reject(false);
5568
+ });
5569
+ });
5570
+ };
5571
+
5535
5572
  const addFavoritesCategory = () => {
5536
5573
  if (favoritesAdded == false && favorites == "true") {
5537
5574
  categories.splice(1, 0, {
@@ -5543,22 +5580,30 @@
5543
5580
  }
5544
5581
 
5545
5582
  favoritesAdded = true;
5546
- $$invalidate(3, isLoading = false);
5583
+ favoritesLoaded = true;
5547
5584
  };
5548
5585
 
5586
+ let isLoadingMostPlayed = false;
5587
+
5549
5588
  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
- }
5589
+ $$invalidate(8, isLoadingMostPlayed = true);
5590
+
5591
+ getMostPlayedGames().then(display => {
5592
+ if (mostPlayedAdded == false && mostplayed == "true" && display) {
5593
+ categories.splice(2, 0, {
5594
+ id: "MOSTPLAYED",
5595
+ name: "Most Played",
5596
+ href: "",
5597
+ games: [],
5598
+ triggerFetch: false
5599
+ });
5600
+ }
5559
5601
 
5560
- mostPlayedAdded = true;
5561
- $$invalidate(3, isLoading = false);
5602
+ $$invalidate(8, isLoadingMostPlayed = false);
5603
+ tick();
5604
+ mostPlayedAdded = true;
5605
+ mostPlayedLoaded = true;
5606
+ });
5562
5607
  };
5563
5608
 
5564
5609
  const checkAttrs = () => {
@@ -5586,14 +5631,15 @@
5586
5631
  return hasErrors;
5587
5632
  };
5588
5633
 
5634
+ const checkIfLoaded = () => {
5635
+ $$invalidate(3, isLoading = !favoritesLoaded && !mostPlayedLoaded && !categoriesLoaded);
5636
+ };
5637
+
5589
5638
  const initialLoad = () => {
5590
5639
  if (!checkAttrs()) {
5591
- $$invalidate(3, isLoading = true);
5592
5640
  let url = new URL(`${endpoint}/casino/groups/${datasource}`);
5593
5641
  url.searchParams.append("datasource", datasource);
5594
-
5595
- // @TODO add back getDevice method
5596
- // url.searchParams.append('platform', getDevice(userAgent));
5642
+ url.searchParams.append("platform", getDevice(userAgent));
5597
5643
  url.searchParams.append("language", lang);
5598
5644
 
5599
5645
  fetch(url).then(res => res.json()).then(
@@ -5613,8 +5659,8 @@
5613
5659
  games: []
5614
5660
  });
5615
5661
 
5616
- window.postMessage({ type: "CategoriesLoadedForSlider" }, window.location.href);
5617
5662
  $$invalidate(3, isLoading = false);
5663
+ window.postMessage({ type: "CategoriesLoadedForSlider" }, window.location.href);
5618
5664
  },
5619
5665
  err => {
5620
5666
  $$invalidate(5, hasErrors = true);
@@ -5649,8 +5695,9 @@
5649
5695
 
5650
5696
  const setClientStylingURL = () => {
5651
5697
  let cssFile = document.createElement("style");
5698
+ let url = new URL(clientstylingurl);
5652
5699
 
5653
- fetch(new URL(clientstylingurl)).then(res => res.text()).then(data => {
5700
+ fetch(url.href).then(res => res.text()).then(data => {
5654
5701
  cssFile.innerHTML = data;
5655
5702
 
5656
5703
  setTimeout(
@@ -5674,6 +5721,7 @@
5674
5721
  "endpoint",
5675
5722
  "datasource",
5676
5723
  "lang",
5724
+ "userid",
5677
5725
  "session",
5678
5726
  "mostplayed",
5679
5727
  "favorites",
@@ -5694,12 +5742,13 @@
5694
5742
  }
5695
5743
 
5696
5744
  $$self.$$set = $$props => {
5697
- if ("endpoint" in $$props) $$invalidate(8, endpoint = $$props.endpoint);
5698
- if ("datasource" in $$props) $$invalidate(9, datasource = $$props.datasource);
5699
- 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);
5745
+ if ("endpoint" in $$props) $$invalidate(9, endpoint = $$props.endpoint);
5746
+ if ("datasource" in $$props) $$invalidate(10, datasource = $$props.datasource);
5747
+ if ("lang" in $$props) $$invalidate(11, lang = $$props.lang);
5748
+ if ("userid" in $$props) $$invalidate(12, userid = $$props.userid);
5749
+ if ("session" in $$props) $$invalidate(13, session = $$props.session);
5750
+ if ("mostplayed" in $$props) $$invalidate(14, mostplayed = $$props.mostplayed);
5751
+ if ("favorites" in $$props) $$invalidate(15, favorites = $$props.favorites);
5703
5752
  if ("clientstyling" in $$props) $$invalidate(0, clientstyling = $$props.clientstyling);
5704
5753
  if ("clientstylingurl" in $$props) $$invalidate(1, clientstylingurl = $$props.clientstylingurl);
5705
5754
  if ("containermaxwidth" in $$props) $$invalidate(2, containermaxwidth = $$props.containermaxwidth);
@@ -5707,11 +5756,13 @@
5707
5756
 
5708
5757
  $$self.$capture_state = () => ({
5709
5758
  onMount,
5759
+ tick,
5710
5760
  getDevice,
5711
5761
  checkSession,
5712
5762
  endpoint,
5713
5763
  datasource,
5714
5764
  lang,
5765
+ userid,
5715
5766
  session,
5716
5767
  mostplayed,
5717
5768
  favorites,
@@ -5731,10 +5782,16 @@
5731
5782
  numberOfFavoredGames,
5732
5783
  favoritesAdded,
5733
5784
  mostPlayedAdded,
5785
+ favoritesLoaded,
5786
+ mostPlayedLoaded,
5787
+ categoriesLoaded,
5734
5788
  messageHandler,
5789
+ getMostPlayedGames,
5735
5790
  addFavoritesCategory,
5791
+ isLoadingMostPlayed,
5736
5792
  addMostPlayedCategory,
5737
5793
  checkAttrs,
5794
+ checkIfLoaded,
5738
5795
  initialLoad,
5739
5796
  setSession,
5740
5797
  setClientStyling,
@@ -5742,12 +5799,13 @@
5742
5799
  });
5743
5800
 
5744
5801
  $$self.$inject_state = $$props => {
5745
- if ("endpoint" in $$props) $$invalidate(8, endpoint = $$props.endpoint);
5746
- if ("datasource" in $$props) $$invalidate(9, datasource = $$props.datasource);
5747
- 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);
5802
+ if ("endpoint" in $$props) $$invalidate(9, endpoint = $$props.endpoint);
5803
+ if ("datasource" in $$props) $$invalidate(10, datasource = $$props.datasource);
5804
+ if ("lang" in $$props) $$invalidate(11, lang = $$props.lang);
5805
+ if ("userid" in $$props) $$invalidate(12, userid = $$props.userid);
5806
+ if ("session" in $$props) $$invalidate(13, session = $$props.session);
5807
+ if ("mostplayed" in $$props) $$invalidate(14, mostplayed = $$props.mostplayed);
5808
+ if ("favorites" in $$props) $$invalidate(15, favorites = $$props.favorites);
5751
5809
  if ("clientstyling" in $$props) $$invalidate(0, clientstyling = $$props.clientstyling);
5752
5810
  if ("clientstylingurl" in $$props) $$invalidate(1, clientstylingurl = $$props.clientstylingurl);
5753
5811
  if ("containermaxwidth" in $$props) $$invalidate(2, containermaxwidth = $$props.containermaxwidth);
@@ -5764,6 +5822,10 @@
5764
5822
  if ("numberOfFavoredGames" in $$props) $$invalidate(7, numberOfFavoredGames = $$props.numberOfFavoredGames);
5765
5823
  if ("favoritesAdded" in $$props) favoritesAdded = $$props.favoritesAdded;
5766
5824
  if ("mostPlayedAdded" in $$props) mostPlayedAdded = $$props.mostPlayedAdded;
5825
+ if ("favoritesLoaded" in $$props) favoritesLoaded = $$props.favoritesLoaded;
5826
+ if ("mostPlayedLoaded" in $$props) mostPlayedLoaded = $$props.mostPlayedLoaded;
5827
+ if ("categoriesLoaded" in $$props) categoriesLoaded = $$props.categoriesLoaded;
5828
+ if ("isLoadingMostPlayed" in $$props) $$invalidate(8, isLoadingMostPlayed = $$props.isLoadingMostPlayed);
5767
5829
  };
5768
5830
 
5769
5831
  if ($$props && "$$inject" in $$props) {
@@ -5771,27 +5833,28 @@
5771
5833
  }
5772
5834
 
5773
5835
  $$self.$$.update = () => {
5774
- if ($$self.$$.dirty & /*endpoint, datasource, lang*/ 1792) {
5836
+ if ($$self.$$.dirty[0] & /*endpoint, datasource, lang*/ 3584) {
5837
+ // $: favoritesLoaded && mostPlayedLoaded && categoriesLoaded && checkIfLoaded();
5775
5838
  endpoint && datasource && lang && initialLoad();
5776
5839
  }
5777
5840
 
5778
- if ($$self.$$.dirty & /*session, endpoint*/ 2304) {
5841
+ if ($$self.$$.dirty[0] & /*session, endpoint*/ 8704) {
5779
5842
  session && endpoint && setSession();
5780
5843
  }
5781
5844
 
5782
- if ($$self.$$.dirty & /*session, favorites*/ 10240) {
5845
+ if ($$self.$$.dirty[0] & /*session, favorites*/ 40960) {
5783
5846
  session && favorites && addFavoritesCategory();
5784
5847
  }
5785
5848
 
5786
- if ($$self.$$.dirty & /*session, mostplayed*/ 6144) {
5787
- session && mostplayed && addMostPlayedCategory();
5849
+ if ($$self.$$.dirty[0] & /*session, userid, mostplayed*/ 28672) {
5850
+ session && userid && mostplayed && addMostPlayedCategory();
5788
5851
  }
5789
5852
 
5790
- if ($$self.$$.dirty & /*clientstyling*/ 1) {
5853
+ if ($$self.$$.dirty[0] & /*clientstyling*/ 1) {
5791
5854
  clientstyling && setClientStyling();
5792
5855
  }
5793
5856
 
5794
- if ($$self.$$.dirty & /*clientstylingurl*/ 2) {
5857
+ if ($$self.$$.dirty[0] & /*clientstylingurl*/ 2) {
5795
5858
  clientstylingurl && setClientStylingURL();
5796
5859
  }
5797
5860
  };
@@ -5807,9 +5870,11 @@
5807
5870
  hasErrors,
5808
5871
  customStylingContainer,
5809
5872
  numberOfFavoredGames,
5873
+ isLoadingMostPlayed,
5810
5874
  endpoint,
5811
5875
  datasource,
5812
5876
  lang,
5877
+ userid,
5813
5878
  session,
5814
5879
  mostplayed,
5815
5880
  favorites,
@@ -5833,16 +5898,18 @@
5833
5898
  create_fragment,
5834
5899
  safe_not_equal,
5835
5900
  {
5836
- endpoint: 8,
5837
- datasource: 9,
5838
- lang: 10,
5839
- session: 11,
5840
- mostplayed: 12,
5841
- favorites: 13,
5901
+ endpoint: 9,
5902
+ datasource: 10,
5903
+ lang: 11,
5904
+ userid: 12,
5905
+ session: 13,
5906
+ mostplayed: 14,
5907
+ favorites: 15,
5842
5908
  clientstyling: 0,
5843
5909
  clientstylingurl: 1,
5844
5910
  containermaxwidth: 2
5845
- }
5911
+ },
5912
+ [-1, -1]
5846
5913
  );
5847
5914
 
5848
5915
  if (options) {
@@ -5862,6 +5929,7 @@
5862
5929
  "endpoint",
5863
5930
  "datasource",
5864
5931
  "lang",
5932
+ "userid",
5865
5933
  "session",
5866
5934
  "mostplayed",
5867
5935
  "favorites",
@@ -5872,7 +5940,7 @@
5872
5940
  }
5873
5941
 
5874
5942
  get endpoint() {
5875
- return this.$$.ctx[8];
5943
+ return this.$$.ctx[9];
5876
5944
  }
5877
5945
 
5878
5946
  set endpoint(endpoint) {
@@ -5881,7 +5949,7 @@
5881
5949
  }
5882
5950
 
5883
5951
  get datasource() {
5884
- return this.$$.ctx[9];
5952
+ return this.$$.ctx[10];
5885
5953
  }
5886
5954
 
5887
5955
  set datasource(datasource) {
@@ -5890,7 +5958,7 @@
5890
5958
  }
5891
5959
 
5892
5960
  get lang() {
5893
- return this.$$.ctx[10];
5961
+ return this.$$.ctx[11];
5894
5962
  }
5895
5963
 
5896
5964
  set lang(lang) {
@@ -5898,8 +5966,17 @@
5898
5966
  flush();
5899
5967
  }
5900
5968
 
5969
+ get userid() {
5970
+ return this.$$.ctx[12];
5971
+ }
5972
+
5973
+ set userid(userid) {
5974
+ this.$set({ userid });
5975
+ flush();
5976
+ }
5977
+
5901
5978
  get session() {
5902
- return this.$$.ctx[11];
5979
+ return this.$$.ctx[13];
5903
5980
  }
5904
5981
 
5905
5982
  set session(session) {
@@ -5908,7 +5985,7 @@
5908
5985
  }
5909
5986
 
5910
5987
  get mostplayed() {
5911
- return this.$$.ctx[12];
5988
+ return this.$$.ctx[14];
5912
5989
  }
5913
5990
 
5914
5991
  set mostplayed(mostplayed) {
@@ -5917,7 +5994,7 @@
5917
5994
  }
5918
5995
 
5919
5996
  get favorites() {
5920
- return this.$$.ctx[13];
5997
+ return this.$$.ctx[15];
5921
5998
  }
5922
5999
 
5923
6000
  set favorites(favorites) {