@everymatrix/casino-categories-slider 0.0.395 → 0.0.398
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-categories-slider",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.398",
|
|
4
4
|
"main": "dist/casino-categories-slider.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": "
|
|
39
|
+
"gitHead": "a6034652886209b6fcdc64d039abe2fb2760c472"
|
|
40
40
|
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { getDevice, checkSession, platformFavorite } from 'rvhelper';
|
|
6
6
|
|
|
7
7
|
import type { CategoriesData, CategoriesItems } from './CasinoCategoriesSlider.types';
|
|
8
|
-
|
|
9
8
|
import '@everymatrix/casino-slider';
|
|
10
9
|
|
|
11
10
|
export let endpoint:string = '';
|
|
@@ -15,6 +14,8 @@
|
|
|
15
14
|
export let session:string = ''; // Value for sessionID
|
|
16
15
|
export let mostplayed:string = ''; // True - add MostPlayed category in slider
|
|
17
16
|
export let mostplayedrounds:string = '';
|
|
17
|
+
export let lastplayed:string = 'false'; // True - add LastPlayed category in slider
|
|
18
|
+
export let lastplayedperiod:string = ''; // The period of the query (Last30Days|Last7Days|Yesterday|Today)
|
|
18
19
|
export let favorites:string = ''; // True - add Favorites category in slider
|
|
19
20
|
export let clientstyling:string = '';
|
|
20
21
|
export let clientstylingurl:string = '';
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
export let sessioncheck:string = '';
|
|
25
26
|
export let location:string = "secondaryMenu";
|
|
26
27
|
export let showsubgroups:string = 'false';
|
|
27
|
-
|
|
28
|
+
export let filteredcategories:string = '';
|
|
28
29
|
|
|
29
30
|
let identity:string = 'CasinoSliderData'
|
|
30
31
|
|
|
@@ -48,10 +49,13 @@
|
|
|
48
49
|
let numberOfFavoredGames:number;
|
|
49
50
|
let favoritesAdded:boolean = false;
|
|
50
51
|
let mostPlayedAdded:boolean = false;
|
|
52
|
+
let lastPlayedAdded:boolean = false;
|
|
51
53
|
let favoritesLoaded:boolean = false;
|
|
52
54
|
let mostPlayedLoaded:boolean = false;
|
|
55
|
+
let lastPlayedLoaded:boolean = false;
|
|
53
56
|
let categoriesLoaded:boolean = false;
|
|
54
57
|
let isLoadingMostPlayed:boolean = false;
|
|
58
|
+
let isLoadingLastPlayed:boolean = false;
|
|
55
59
|
|
|
56
60
|
$: numberOfFavoredGames = 0;
|
|
57
61
|
|
|
@@ -102,6 +106,41 @@
|
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
|
|
109
|
+
const getLastPlayedGames = ():Promise<any> => {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
if (lastplayed) {
|
|
112
|
+
let url:URL = new URL(`${endpoint}/player/${userid}/games/last-played`);
|
|
113
|
+
|
|
114
|
+
let device = getDevice(userAgent);
|
|
115
|
+
|
|
116
|
+
if (device) {
|
|
117
|
+
if (device === 'PC') {
|
|
118
|
+
url.searchParams.append('device', 'Desktop');
|
|
119
|
+
} else {
|
|
120
|
+
url.searchParams.append('device', 'Mobile');
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
url.searchParams.append('device', 'All');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
url.searchParams.append('period', lastplayedperiod);
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
fetch(url.href)
|
|
130
|
+
.then((res:any) => res.json())
|
|
131
|
+
.then((data:any) => {
|
|
132
|
+
if (data.count == 0) {
|
|
133
|
+
resolve(false);
|
|
134
|
+
}
|
|
135
|
+
resolve(data);
|
|
136
|
+
}).catch((err:any) => {
|
|
137
|
+
console.error('err', err);
|
|
138
|
+
reject(false);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
105
144
|
const addFavoritesCategory = ():void => {
|
|
106
145
|
if (favoritesAdded == false && favorites == 'true') {
|
|
107
146
|
categories.splice(1, 0, {
|
|
@@ -142,6 +181,31 @@
|
|
|
142
181
|
}
|
|
143
182
|
}
|
|
144
183
|
|
|
184
|
+
const addLastPlayedCategory = ():void => {
|
|
185
|
+
if (lastplayed == 'true') {
|
|
186
|
+
isLoadingLastPlayed = true;
|
|
187
|
+
|
|
188
|
+
getLastPlayedGames().then((display:boolean) => {
|
|
189
|
+
if (lastPlayedAdded == false && lastplayed == 'true' && display) {
|
|
190
|
+
categories.splice(3, 0, {
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
id: 'LASTPLAYED',
|
|
193
|
+
name: 'Last Played',
|
|
194
|
+
href: '',
|
|
195
|
+
games: [],
|
|
196
|
+
triggerFetch: false
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
isLoadingLastPlayed = false;
|
|
201
|
+
tick();
|
|
202
|
+
|
|
203
|
+
lastPlayedAdded = true;
|
|
204
|
+
lastPlayedLoaded = true;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
145
209
|
const checkAttrs = ():boolean => {
|
|
146
210
|
if (!endpoint) {
|
|
147
211
|
error = "Endpoint is missing! Please provide a valid endpointURL.";
|
|
@@ -171,7 +235,7 @@
|
|
|
171
235
|
}
|
|
172
236
|
|
|
173
237
|
const checkIfLoaded = ():void => {
|
|
174
|
-
isLoading = !favoritesLoaded && !mostPlayedLoaded && !categoriesLoaded;
|
|
238
|
+
isLoading = !favoritesLoaded && !mostPlayedLoaded && !lastPlayedLoaded && !categoriesLoaded;
|
|
175
239
|
}
|
|
176
240
|
|
|
177
241
|
const initialLoad = ():void => {
|
|
@@ -185,9 +249,19 @@
|
|
|
185
249
|
fetch(url)
|
|
186
250
|
.then((res:any) => res.json())
|
|
187
251
|
.then((data:CategoriesData) => {
|
|
252
|
+
//create an array of filtered categories
|
|
253
|
+
let arrayFilteredCategories = filteredcategories.split(',');
|
|
188
254
|
// filter type added to type
|
|
189
255
|
let arr = data.items.filter((item:any) => {
|
|
190
|
-
|
|
256
|
+
let filtered;
|
|
257
|
+
if( item.games.total > 0) {
|
|
258
|
+
filtered = true;
|
|
259
|
+
//exclude filtered categories
|
|
260
|
+
for (let element of arrayFilteredCategories){
|
|
261
|
+
if( item.flags == element ) filtered = false;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
return filtered;
|
|
191
265
|
});
|
|
192
266
|
|
|
193
267
|
categories = [];
|
|
@@ -269,14 +343,15 @@
|
|
|
269
343
|
$: endpoint && datasource && lang && initialLoad();
|
|
270
344
|
$: session && endpoint && setSession();
|
|
271
345
|
$: session && favorites && !isLoading && addFavoritesCategory();
|
|
272
|
-
$: session && endpoint &&
|
|
346
|
+
$: session && endpoint && !isLoading && lastplayed && addLastPlayedCategory();
|
|
347
|
+
$: session && endpoint && !isLoading && userid && mostplayed && addMostPlayedCategory();
|
|
273
348
|
$: !isLoading && activecategory && setActiveCategory();
|
|
274
349
|
$: clientstyling && setClientStyling();
|
|
275
350
|
$: clientstylingurl && setClientStylingURL();
|
|
276
351
|
</script>
|
|
277
352
|
|
|
278
353
|
<div bind:this={customStylingContainer} part="CustomStylingContainer">
|
|
279
|
-
{#if isLoading || isLoadingMostPlayed}
|
|
354
|
+
{#if isLoading || isLoadingMostPlayed || isLoadingLastPlayed}
|
|
280
355
|
<div class="CasinoCategoriesLoading" part="CasinoCategoriesLoading"></div>
|
|
281
356
|
{:else}
|
|
282
357
|
{#if hasErrors}
|