@@ -27,10 +27,10 @@ const initTournamentChannel = (dispatch, isAdminWidged = false) => {
2727
2828 const onJoinSuccess = response => {
2929 if ( isAdminWidged ) {
30- // Handle active_game_id if it exists in the response
31- if ( response . activeGameId ) {
32- dispatch ( actions . setAdminActiveGameId ( response . activeGameId ) ) ;
33- }
30+ // Handle active_game_id if it exists in the response
31+ if ( response . activeGameId ) {
32+ dispatch ( actions . setAdminActiveGameId ( response . activeGameId ) ) ;
33+ }
3434 dispatch (
3535 actions . setTournamentData ( {
3636 ...response . tournament ,
@@ -43,7 +43,7 @@ const initTournamentChannel = (dispatch, isAdminWidged = false) => {
4343 ) ;
4444 }
4545
46- dispatch ( actions . updateTournamentRanking ( ( response . ranking ) ) ) ;
46+ dispatch ( actions . updateTournamentRanking ( response . ranking ) ) ;
4747 dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
4848 dispatch ( actions . updateTournamentMatches ( compact ( response . matches ) ) ) ;
4949 dispatch ( actions . setTournamentTaskList ( compact ( response . tasksInfo ) ) ) ;
@@ -60,101 +60,105 @@ const initTournamentChannel = (dispatch, isAdminWidged = false) => {
6060// export const soundNotification = notification();
6161
6262export const connectToTournament = ( _machine , newTournamentId , isAdminWidged = false ) => dispatch => {
63- setTournamentChannel ( newTournamentId ) ;
64- initTournamentChannel ( dispatch , isAdminWidged ) ;
65-
66- const handleUpdate = response => {
67- dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
68- dispatch ( actions . updateTournamentPlayers ( compact ( response . players || [ ] ) ) ) ;
69- dispatch ( actions . updateTournamentMatches ( compact ( response . matches || [ ] ) ) ) ;
70- if ( response . ranking ) {
71- dispatch ( actions . updateTournamentRanking ( ( response . ranking ) ) ) ;
72- }
73- if ( response . tasksInfo ) {
74- dispatch ( actions . setTournamentTaskList ( compact ( response . tasksInfo ) ) ) ;
75- }
76- } ;
63+ setTournamentChannel ( newTournamentId ) ;
64+ initTournamentChannel ( dispatch , isAdminWidged ) ;
7765
78- const handleReportPending = response => {
79- dispatch ( actions . addReport ( response . report ) ) ;
80- } ;
66+ const handleUpdate = response => {
67+ dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
68+ dispatch (
69+ actions . updateTournamentPlayers ( compact ( response . players || [ ] ) ) ,
70+ ) ;
71+ dispatch (
72+ actions . updateTournamentMatches ( compact ( response . matches || [ ] ) ) ,
73+ ) ;
74+ if ( response . ranking ) {
75+ dispatch ( actions . updateTournamentRanking ( response . ranking ) ) ;
76+ }
77+ if ( response . tasksInfo ) {
78+ dispatch ( actions . setTournamentTaskList ( compact ( response . tasksInfo ) ) ) ;
79+ }
80+ } ;
8181
82- const handleReportUpdated = response => {
83- dispatch ( actions . updateReport ( response . report ) ) ;
84- } ;
82+ const handleReportPending = response => {
83+ dispatch ( actions . addReport ( response . report ) ) ;
84+ } ;
8585
86- const handleMatchesUpdate = response => {
87- dispatch ( actions . updateTournamentMatches ( compact ( response . matches ) ) ) ;
88- } ;
86+ const handleReportUpdated = response => {
87+ dispatch ( actions . updateReport ( response . report ) ) ;
88+ } ;
8989
90- const handlePlayersUpdate = response => {
91- dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
92- } ;
90+ const handleMatchesUpdate = response => {
91+ dispatch ( actions . updateTournamentMatches ( compact ( response . matches ) ) ) ;
92+ } ;
9393
94- const handleTournamentRoundCreated = response => {
95- dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
96- } ;
94+ const handlePlayersUpdate = response => {
95+ dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
96+ } ;
9797
98- const handleRoundFinished = response => {
99- dispatch (
100- actions . updateTournamentData ( {
101- ...response . tournament ,
102- topPlayerIds : response . topPlayerIds ,
103- playersPageNumber : 1 ,
104- playersPageSize : 20 ,
105- } ) ,
106- ) ;
98+ const handleTournamentRoundCreated = response => {
99+ dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
100+ } ;
107101
108- dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
109- dispatch ( actions . updateTopPlayers ( compact ( response . players ) ) ) ;
110- } ;
102+ const handleRoundFinished = response => {
103+ dispatch (
104+ actions . updateTournamentData ( {
105+ ...response . tournament ,
106+ topPlayerIds : response . topPlayerIds ,
107+ playersPageNumber : 1 ,
108+ playersPageSize : 20 ,
109+ } ) ,
110+ ) ;
111111
112- const handleTournamentRestarted = response => {
113- dispatch (
114- actions . setTournamentData ( {
115- ...response . tournament ,
116- channel : { online : true } ,
117- playersPageNumber : 1 ,
118- playersPageSize : 20 ,
119- matches : { } ,
120- players : { } ,
121- } ) ,
122- ) ;
123- } ;
112+ dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
113+ dispatch ( actions . updateTopPlayers ( compact ( response . players ) ) ) ;
114+ } ;
124115
125- const handlePlayerJoined = response => {
126- dispatch ( actions . addTournamentPlayer ( response ) ) ;
127- dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
128- } ;
116+ const handleTournamentRestarted = response => {
117+ dispatch (
118+ actions . setTournamentData ( {
119+ ...response . tournament ,
120+ channel : { online : true } ,
121+ playersPageNumber : 1 ,
122+ playersPageSize : 20 ,
123+ matches : { } ,
124+ players : { } ,
125+ } ) ,
126+ ) ;
127+ } ;
129128
130- const handlePlayerLeft = response => {
131- dispatch ( actions . removeTournamentPlayer ( response ) ) ;
132- dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
133- } ;
129+ const handlePlayerJoined = response => {
130+ dispatch ( actions . addTournamentPlayer ( response ) ) ;
131+ dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
132+ } ;
134133
135- const handleMatchUpserted = response => {
136- dispatch ( actions . updateTournamentMatches ( compact ( [ response . match ] ) ) ) ;
137- dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
138- } ;
134+ const handlePlayerLeft = response => {
135+ dispatch ( actions . removeTournamentPlayer ( response ) ) ;
136+ dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
137+ } ;
139138
140- const handleTournamentFinished = response => {
141- dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
142- } ;
139+ const handleMatchUpserted = response => {
140+ dispatch ( actions . updateTournamentMatches ( compact ( [ response . match ] ) ) ) ;
141+ dispatch ( actions . updateTournamentPlayers ( compact ( response . players ) ) ) ;
142+ } ;
143143
144- return channel
145- . addListener ( 'tournament:update' , handleUpdate )
146- . addListener ( 'tournament:report:pending' , handleReportPending )
147- . addListener ( 'tournament:report:updated' , handleReportUpdated )
148- . addListener ( 'tournament:matches:update' , handleMatchesUpdate )
149- . addListener ( 'tournament:players:update' , handlePlayersUpdate )
150- . addListener ( 'tournament:round_created' , handleTournamentRoundCreated )
151- . addListener ( 'tournament:round_finished' , handleRoundFinished )
152- . addListener ( 'tournament:player:joined' , handlePlayerJoined )
153- . addListener ( 'tournament:player:left' , handlePlayerLeft )
154- . addListener ( 'tournament:match:upserted' , handleMatchUpserted )
155- . addListener ( 'tournament:restarted' , handleTournamentRestarted )
156- . addListener ( 'tournament:finished' , handleTournamentFinished ) ;
157- } ;
144+ const handleTournamentFinished = response => {
145+ dispatch ( actions . updateTournamentData ( response . tournament ) ) ;
146+ } ;
147+
148+ return channel
149+ . addListener ( 'tournament:update' , handleUpdate )
150+ . addListener ( 'tournament:report:pending' , handleReportPending )
151+ . addListener ( 'tournament:report:updated' , handleReportUpdated )
152+ . addListener ( 'tournament:matches:update' , handleMatchesUpdate )
153+ . addListener ( 'tournament:players:update' , handlePlayersUpdate )
154+ . addListener ( 'tournament:round_created' , handleTournamentRoundCreated )
155+ . addListener ( 'tournament:round_finished' , handleRoundFinished )
156+ . addListener ( 'tournament:player:joined' , handlePlayerJoined )
157+ . addListener ( 'tournament:player:left' , handlePlayerLeft )
158+ . addListener ( 'tournament:match:upserted' , handleMatchUpserted )
159+ . addListener ( 'tournament:restarted' , handleTournamentRestarted )
160+ . addListener ( 'tournament:finished' , handleTournamentFinished ) ;
161+ } ;
158162
159163// TODO (tournaments): request matches by searched player id
160164export const uploadPlayers = playerIds => ( dispatch , getState ) => {
@@ -316,7 +320,9 @@ export const getResults = (type, params, onSuccess) => () => {
316320 const data = camelizeKeys ( payload ) ;
317321
318322 if ( type === PanelModeCodes . topUserByClansMode ) {
319- const result = Object . values ( groupBy ( data . results , item => item . clanRank ) ) ;
323+ const result = Object . values (
324+ groupBy ( data . results , item => item . clanRank ) ,
325+ ) ;
320326 onSuccess ( result ) ;
321327 } else {
322328 onSuccess ( data . results ) ;
@@ -325,13 +331,11 @@ export const getResults = (type, params, onSuccess) => () => {
325331} ;
326332
327333export const getTask = ( taskId , onSuccess ) => ( ) => {
328- channel
329- . push ( 'tournament:get_task' , { taskId } )
330- . receive ( 'ok' , payload => {
331- const data = camelizeKeys ( payload ) ;
334+ channel . push ( 'tournament:get_task' , { taskId } ) . receive ( 'ok' , payload => {
335+ const data = camelizeKeys ( payload ) ;
332336
333- onSuccess ( data . descriptionRu ) ;
334- } ) ;
337+ onSuccess ( data ) ;
338+ } ) ;
335339} ;
336340
337341export const pushActiveMatchToStream = gameId => dispatch => {
0 commit comments