@everymatrix/casino-tournaments-controller 1.15.0 → 1.15.2

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-tournaments-controller",
3
- "version": "1.15.0",
3
+ "version": "1.15.2",
4
4
  "main": "dist/casino-tournaments-controller.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "15ce8765c213b2c036dd5fbc5007d6ea5a666dc1"
38
+ "gitHead": "c590519dbcc5d9ba61081face50b61df6f79981d"
39
39
  }
@@ -9,6 +9,7 @@
9
9
 
10
10
  import '@everymatrix/casino-tournaments-filter-controller';
11
11
  import '@everymatrix/casino-tournaments-list-controller';
12
+ import { isValidSession } from './util';
12
13
 
13
14
  // endpoint for NorWAy
14
15
  export let session:string = '';
@@ -63,6 +64,7 @@
63
64
 
64
65
  let tournamentsSearchParams:string;
65
66
  let tournamentsUpdateEventSource:EventSourcePolyfill;
67
+ let isLoadTriggered = false
66
68
 
67
69
  setupI18n({ withLocale: 'en', translations: {}});
68
70
 
@@ -162,7 +164,7 @@
162
164
  StartTimeAfter: getStartTimeAfter(),
163
165
  }
164
166
 
165
- if(!session && showanonymoustournaments === 'false'){
167
+ if(!isValidSession(session) && showanonymoustournaments === 'false'){
166
168
  filterOptions.tags = 'no-role-set'
167
169
  }
168
170
 
@@ -302,13 +304,21 @@
302
304
  }
303
305
 
304
306
  const setSession = () => {
305
- if (session.length > 0 && session != 'false') {
307
+ if (isValidSession(session)) {
306
308
  isLoggedIn = true;
307
- isLoading = true;
308
309
  sessionID = session;
309
310
  } else {
310
311
  isLoggedIn = false;
311
- initialLoad();
312
+ sessionID = ''
313
+ }
314
+ }
315
+
316
+ // ensure multiple props (from session and others) change just trigger initialLoad only once
317
+ const shouldLoad = async () => {
318
+ if(!isLoadTriggered){
319
+ isLoadTriggered = true
320
+ await initialLoad()
321
+ isLoadTriggered = false
312
322
  }
313
323
  }
314
324
 
@@ -354,15 +364,15 @@
354
364
 
355
365
  $: customStylingContainer && clientstyling && setClientStyling();
356
366
  $: customStylingContainer && clientstylingurl && setClientStylingURL();
357
- $: session && setSession();
358
367
  $: userid && setPlayerID();
359
- $: lang && setLocale(lang);
360
368
  $: filters && setActiveFilters();
361
369
  $: lang && setActiveLanguage();
362
370
  $: translationurl && setTranslationUrl();
363
- $: initialParameters = endpoint && numberoftournaments && showmorestep && lang && showanonymoustournaments;
364
- $: readyToLoad = session ? initialParameters && session : initialParameters;
365
- $: readyToLoad && isMounted && initialLoad();
371
+ $: isMounted && initialLoad();
372
+
373
+ $: if(session === '' || session) setSession()
374
+ $: if(sessionID === '' || sessionID) shouldLoad()
375
+ $: if(endpoint && numberoftournaments && showmorestep && lang && showanonymoustournaments) shouldLoad()
366
376
  </script>
367
377
 
368
378
  <div bind:this={customStylingContainer}>
package/src/util.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export const isValidSession = (session: string) => session.length > 0 && session != 'false'