@everymatrix/casino-last-played-section 1.5.5 → 1.6.0

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/index.html CHANGED
@@ -30,8 +30,8 @@
30
30
  </header>
31
31
 
32
32
  <div class="webcomponent">
33
- <casino-last-played-section endpoint="https://demo-api.stage.norway.everymatrix.com/v1" datasource="RNG"
34
- userid="4506648" session="199e1b3f-cbfa-42ae-83bd-6bf5c738b36b" lang="en">
33
+ <casino-last-played-section endpoint="https://demo-api.stage.norway.everymatrix.com/v1" unique="true" datasource="RNG"
34
+ userid="4506648" session="ce624de8-dd73-49c9-b56a-b81cb84db4b5" lang="en">
35
35
  </casino-last-played-section>
36
36
  </div>
37
37
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-last-played-section",
3
- "version": "1.5.5",
3
+ "version": "1.6.0",
4
4
  "main": "index.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": "394176b807e2523b04e88d04cbdb5d596577547a"
39
+ "gitHead": "e4b57a534bdee7d09fc53a7b49e31338bc1a3f00"
40
40
  }
@@ -22,16 +22,17 @@
22
22
  export let gamepagemodalurl:string = 'false';
23
23
  export let visiblegames:string = '';
24
24
  export let favorites:string = '';
25
- export let lastplayedperiod:string = '';
25
+ export let lastplayedperiod:string = 'Last30Days';
26
+ export let lastplayedorder:string = '';
27
+ export let lastplayedlimit:string = '';
26
28
  export let casinomygames:string = 'false';
29
+ export let lastplayedunique: string = 'true';
27
30
 
28
31
 
29
32
  let userAgent:any = window.navigator.userAgent;
30
33
 
31
34
  let lastPlayedEmpty:boolean = false;
32
35
  let lastPlayedGames:Array<any> = [];
33
- let playerID:string;
34
- let activeCategory:string;
35
36
  let urlCasino:any;
36
37
  let isLoading:boolean = false;
37
38
 
@@ -54,32 +55,20 @@
54
55
  addNewMessages(item, LastPlayedTranslations[item]);
55
56
  });
56
57
 
57
- const getLastPlayedCategory = (options:any) => {
58
+ const getLastPlayedCategory = ():Promise<any> => {
58
59
  return new Promise((resolve, reject) => {
59
60
  let url = new URL(`${endpoint}/player/${userid}/games/last-played`);
60
61
 
61
- if (options.limit) {
62
- url.searchParams.append('limit', '10');
63
- }
64
-
65
- if (options.order) {
66
- url.searchParams.append('order', options.order);
67
- }
62
+ url.searchParams.append('unique', lastplayedunique);
63
+ url.searchParams.append('limit', lastplayedlimit);
64
+ url.searchParams.append('order', lastplayedorder);
65
+ url.searchParams.append('period', lastplayedperiod);
68
66
 
69
- let device = options.device;
70
-
71
- if (device) {
72
- if (device === 'PC') {
73
- url.searchParams.append('device', 'Desktop');
74
- } else {
75
- url.searchParams.append('device', 'Mobile');
76
- }
67
+ let device = getDevice(userAgent);
68
+ if (device === 'PC') {
69
+ url.searchParams.append('device', 'Desktop');
77
70
  } else {
78
- url.searchParams.append('device', 'All');
79
- }
80
-
81
- if (options.period) {
82
- url.searchParams.append('period', 'Last30Days');
71
+ url.searchParams.append('device', 'Mobile');
83
72
  }
84
73
 
85
74
  urlCasino = livecasino ? url : url.href;
@@ -110,35 +99,33 @@
110
99
  isLoading = true;
111
100
 
112
101
  const initialLoad = ():void => {
113
- getLastPlayedCategory({
114
- device: getDevice(userAgent),
115
- period: lastplayedperiod || 'Last30Days'
116
- }).then((res:any) => {
117
- window.postMessage({ type: 'GetFavoredGame' }, window.location.href);
118
- isLoading = false;
119
- if (res.count > 0) {
120
- let promises:any = [];
121
-
122
- res.items.forEach((item:any) => {
123
- let url:URL = new URL(`${endpoint}/casino/games/${item.gameId}`);
124
-
125
- url.searchParams.append('datasource', datasource);
126
- if (livecasino) {
127
- promises.push(fetch(url.href).then((res:any) => res.json()));
128
- } else {
129
- promises.push(fetch(url.href).then((res:any) => res.json()));
130
- }
131
- });
132
-
133
- Promise.all(promises).then((values:any) => {
134
- lastPlayedGames = values.map((item:any) => item[0]);
135
-
136
- window.postMessage({ type: 'LastPlayedData', lastPlayedGames }, window.location.href);
137
- });
102
+ getLastPlayedCategory()
103
+ .then((res:any) => {
104
+ window.postMessage({ type: 'GetFavoredGame' }, window.location.href);
105
+ isLoading = false;
106
+ if (res.count > 0) {
107
+ let promises:any = [];
108
+
109
+ res.items.forEach((item:any) => {
110
+ let url:URL = new URL(`${endpoint}/casino/games/${item.gameId}`);
111
+
112
+ url.searchParams.append('datasource', datasource);
113
+ if (livecasino) {
114
+ promises.push(fetch(url.href).then((res:any) => res.json()));
115
+ } else {
116
+ promises.push(fetch(url.href).then((res:any) => res.json()));
117
+ }
118
+ });
119
+
120
+ Promise.all(promises).then((values:any) => {
121
+ lastPlayedGames = values.map((item:any) => item[0]);
122
+
123
+ window.postMessage({ type: 'LastPlayedData', lastPlayedGames }, window.location.href);
124
+ });
138
125
 
139
- } else {
140
- lastPlayedEmpty = true;
141
- }
126
+ } else {
127
+ lastPlayedEmpty = true;
128
+ }
142
129
  });
143
130
  }
144
131