@everymatrix/casino-tournaments-page-controller 0.0.192 → 0.0.196
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-page-controller",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.196",
|
|
4
4
|
"main": "dist/casino-tournaments-page-controller.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "9809bd993cd1842fb5832ca5b3269eb33d0be029"
|
|
41
41
|
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { isMobile, getDevice, checkSession } from 'rvhelper';
|
|
6
6
|
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
7
7
|
import { TournamentsPageTranslations } from './translations';
|
|
8
|
+
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
8
9
|
|
|
9
10
|
import '@everymatrix/casino-tournaments-page';
|
|
10
11
|
import '@everymatrix/casino-tournaments-details';
|
|
@@ -41,6 +42,8 @@
|
|
|
41
42
|
let firstRowData:any = {};
|
|
42
43
|
let firstRowAvailable:boolean = false;
|
|
43
44
|
|
|
45
|
+
let tableUpdateEventSource:EventSourcePolyfill;
|
|
46
|
+
|
|
44
47
|
setupI18n({ withLocale: 'en', translations: {}});
|
|
45
48
|
|
|
46
49
|
Object.keys(TournamentsPageTranslations).forEach((item:any) => {
|
|
@@ -76,7 +79,39 @@
|
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
return tableData;
|
|
79
|
-
}
|
|
82
|
+
},
|
|
83
|
+
tableUpdateMessageHandler = (message:any)=>{
|
|
84
|
+
if(!message.data){
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
try{
|
|
88
|
+
let messageData:any = message.data;
|
|
89
|
+
let updateTableData:any = JSON.parse(messageData);
|
|
90
|
+
if(!updateTableData || !updateTableData.Items){
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let newTableData = transformTableData(updateTableData.Items);
|
|
94
|
+
if(firstRowAvailable && firstRowData){
|
|
95
|
+
window.postMessage({ type: 'CasinoTableFirstRowData', tableData: firstRowData }, window.location.href);
|
|
96
|
+
}
|
|
97
|
+
window.postMessage({ type: 'CasinoTableDataUpdate', tableData: newTableData}, window.location.href);
|
|
98
|
+
}catch(err){
|
|
99
|
+
console.error(err);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
startupTableDataChangeListener = (tournamentID:String, searchParams:any) =>{
|
|
103
|
+
let endpointURL:String = `${endpoint}/tournaments/${tournamentID}/leaderboard/updates?HeartBeat=false&`;
|
|
104
|
+
endpointURL += searchParams.toString();
|
|
105
|
+
tableUpdateEventSource = new EventSourcePolyfill(endpointURL, {
|
|
106
|
+
headers: {
|
|
107
|
+
'accept': 'text/event-stream',
|
|
108
|
+
'X-SessionID': session
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
if(typeof(tableUpdateEventSource) != "undefined"){
|
|
112
|
+
tableUpdateEventSource.addEventListener('message', tableUpdateMessageHandler);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
80
115
|
|
|
81
116
|
const getData = (endpointURL:String, tourID:String) => {
|
|
82
117
|
let url = new URL(endpointURL + `/tournaments/${tourID}`);
|
|
@@ -132,6 +167,7 @@
|
|
|
132
167
|
if (firstRowAvailable) {
|
|
133
168
|
window.postMessage({ type: 'CasinoTableFirstRowData', tableData: firstRowData }, window.location.href);
|
|
134
169
|
}
|
|
170
|
+
startupTableDataChangeListener(tourID, url.searchParams);
|
|
135
171
|
});
|
|
136
172
|
}
|
|
137
173
|
|
|
@@ -190,6 +226,7 @@
|
|
|
190
226
|
|
|
191
227
|
return () => {
|
|
192
228
|
window.removeEventListener('message', messageHandler);
|
|
229
|
+
tableUpdateEventSource.removeEventListener('message', tableUpdateMessageHandler);
|
|
193
230
|
}
|
|
194
231
|
});
|
|
195
232
|
|
|
@@ -264,6 +301,10 @@
|
|
|
264
301
|
{/if}
|
|
265
302
|
|
|
266
303
|
<style lang="scss">
|
|
304
|
+
:host {
|
|
305
|
+
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
|
|
306
|
+
}
|
|
307
|
+
|
|
267
308
|
*,
|
|
268
309
|
*::before,
|
|
269
310
|
*::after {
|
|
@@ -273,7 +314,6 @@
|
|
|
273
314
|
text-decoration: none;
|
|
274
315
|
outline: none;
|
|
275
316
|
box-sizing: border-box;
|
|
276
|
-
font-family: "Helvetica Neue", "Helvetica", sans-serif;
|
|
277
317
|
}
|
|
278
318
|
|
|
279
319
|
.TournamentsPage {
|