Skip to content

Commit 6eb3c30

Browse files
committed
Fix FE warnings
1 parent 602181c commit 6eb3c30

File tree

10 files changed

+136
-130
lines changed

10 files changed

+136
-130
lines changed

services/app/apps/codebattle/assets/js/widgets/components/Editor.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ import EditorLoading from './EditorLoading';
1313

1414
function Editor(props) {
1515
const {
16-
value, syntax, onChange, theme, loading = false, mode,
16+
value,
17+
syntax = 'js',
18+
onChange,
19+
theme,
20+
loading = false,
21+
mode,
22+
wordWrap = 'off',
23+
lineNumbers = 'on',
24+
fontSize = 16,
25+
mute = true,
26+
editable = false,
27+
toggleMuteSound = actions.toggleMuteSound,
1728
} = props;
1829

1930
// Map your custom language key to an actual Monaco recognized language
@@ -112,15 +123,4 @@ Editor.propTypes = {
112123
userId: PropTypes.number.isRequired,
113124
};
114125

115-
Editor.defaultProps = {
116-
wordWrap: 'off',
117-
lineNumbers: 'on',
118-
syntax: 'js',
119-
fontSize: 16,
120-
mute: true,
121-
editable: false,
122-
loading: false,
123-
toggleMuteSound: actions.toggleMuteSound,
124-
};
125-
126126
export default memo(Editor);

services/app/apps/codebattle/assets/js/widgets/components/PopoverStickOnHover.jsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import Popover from 'react-bootstrap/Popover';
77

88
function PopoverStickOnHover({
99
id,
10-
delay,
11-
onMouseEnter,
10+
delay = 0,
11+
onMouseEnter = () => { },
1212
children,
1313
component,
1414
placement,
@@ -81,9 +81,4 @@ PopoverStickOnHover.propTypes = {
8181
placement: PropTypes.string.isRequired,
8282
};
8383

84-
PopoverStickOnHover.defaultProps = {
85-
delay: 0,
86-
onMouseEnter: () => { },
87-
};
88-
8984
export default PopoverStickOnHover;

services/app/apps/codebattle/assets/js/widgets/pages/game/GameWidget.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import React, { useState, useContext, memo } from 'react';
1+
import React, { useState, useContext, memo, useMemo } from 'react';
22

33
import cn from 'classnames';
44
import i18next from 'i18next';
5+
import isEqual from 'lodash/isEqual';
56
import { useSelector } from 'react-redux';
67

78
// import ExtendedEditor from '../../components/ExtendedEditor';
@@ -78,7 +79,12 @@ function GameWidget({ viewMode, editorMachine }) {
7879
const { mainService } = useContext(RoomContext);
7980
const roomMachineState = useMachineStateSelector(mainService, roomStateSelector);
8081

81-
const editors = useSelector(editorsPanelOptionsSelector(viewMode, roomMachineState));
82+
const selector = useMemo(
83+
() => editorsPanelOptionsSelector(viewMode, roomMachineState),
84+
[viewMode, roomMachineState],
85+
);
86+
87+
const editors = useSelector(selector, isEqual);
8288

8389
return (
8490
<>

services/app/apps/codebattle/assets/js/widgets/slices/completedGames.js

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,40 @@ const completedGames = createSlice({
5555
error: null,
5656
},
5757
reducers: {},
58-
extraReducers: {
59-
[fetchCompletedGames.pending]: state => {
60-
state.status = fetchionStatuses.loading;
61-
state.error = null;
62-
},
63-
[fetchCompletedGames.fulfilled]: (state, { payload }) => {
64-
state.status = fetchionStatuses.loaded;
65-
state.completedGames = payload.games;
66-
state.totalPages = payload.pageInfo.totalPages;
67-
state.currrentPage = payload.pageInfo.pageNumber;
68-
state.totalGames = payload.pageInfo.totalEntries;
69-
},
70-
[fetchCompletedGames.rejected]: (state, action) => {
71-
state.status = fetchionStatuses.rejected;
72-
state.error = action.error;
73-
},
74-
[loadNextPage.pending]: state => {
75-
state.status = fetchionStatuses.loading;
76-
state.error = null;
77-
},
78-
[loadNextPage.fulfilled]: (state, { payload }) => {
79-
state.status = fetchionStatuses.loaded;
80-
state.currrentPage = payload.pageInfo.pageNumber;
81-
state.completedGames = unionBy(state.completedGames, payload.games, 'id');
82-
},
83-
[loadNextPage.rejected]: (state, action) => {
84-
state.status = fetchionStatuses.rejected;
85-
state.error = action.error;
86-
},
87-
[lobbyActions.finishGame]: (state, { payload: { game } }) => {
88-
state.completedGames = [game, ...state.completedGames];
89-
state.totalGames += 1;
90-
},
58+
extraReducers: builder => {
59+
builder
60+
.addCase(fetchCompletedGames.pending, state => {
61+
state.status = fetchionStatuses.loading;
62+
state.error = null;
63+
})
64+
.addCase(fetchCompletedGames.fulfilled, (state, { payload }) => {
65+
state.status = fetchionStatuses.loaded;
66+
state.completedGames = payload.games;
67+
state.totalPages = payload.pageInfo.totalPages;
68+
state.currrentPage = payload.pageInfo.pageNumber;
69+
state.totalGames = payload.pageInfo.totalEntries;
70+
})
71+
.addCase(fetchCompletedGames.rejected, (state, action) => {
72+
state.status = fetchionStatuses.rejected;
73+
state.error = action.error;
74+
})
75+
.addCase(loadNextPage.pending, state => {
76+
state.status = fetchionStatuses.loading;
77+
state.error = null;
78+
})
79+
.addCase(loadNextPage.fulfilled, (state, { payload }) => {
80+
state.status = fetchionStatuses.loaded;
81+
state.currrentPage = payload.pageInfo.pageNumber;
82+
state.completedGames = unionBy(state.completedGames, payload.games, 'id');
83+
})
84+
.addCase(loadNextPage.rejected, (state, action) => {
85+
state.status = fetchionStatuses.rejected;
86+
state.error = action.error;
87+
})
88+
.addCase(lobbyActions.finishGame, (state, { payload: { game } }) => {
89+
state.completedGames = [game, ...state.completedGames];
90+
state.totalGames += 1;
91+
});
9192
},
9293
});
9394

services/app/apps/codebattle/assets/js/widgets/slices/editor.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,23 @@ const meta = createSlice({
5858
const text = createSlice({
5959
name: 'text',
6060
initialState: initial.editor.text,
61-
extraReducers: {
62-
[meta.actions.updateEditorText]: (
61+
extraReducers: builder => {
62+
builder.addCase(meta.actions.updateEditorText, (
6363
state,
6464
{ payload: { userId, langSlug, editorText } },
6565
) => {
6666
state[makeEditorTextKey(userId, langSlug)] = editorText;
67-
},
67+
});
6868
},
6969
});
7070

7171
const textHistory = createSlice({
7272
name: 'textHistory',
7373
initialState: initial.editor.textHistory,
74-
extraReducers: {
75-
[meta.actions.updateEditorTextHistory]: (state, { payload: { userId, editorText } }) => {
74+
extraReducers: builder => {
75+
builder.addCase(meta.actions.updateEditorTextHistory, (state, { payload: { userId, editorText } }) => {
7676
state[userId] = editorText;
77-
},
77+
});
7878
},
7979
});
8080

@@ -91,10 +91,10 @@ const langs = createSlice({
9191
const langsHistory = createSlice({
9292
name: 'langsHistory',
9393
initialState: initial.editor.langsHistory,
94-
extraReducers: {
95-
[meta.actions.updateEditorTextHistory]: (state, { payload: { userId, langSlug } }) => {
94+
extraReducers: builder => {
95+
builder.addCase(meta.actions.updateEditorTextHistory, (state, { payload: { userId, langSlug } }) => {
9696
state[userId] = langSlug;
97-
},
97+
});
9898
},
9999
});
100100

services/app/apps/codebattle/assets/js/widgets/slices/event.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,24 @@ const eventSlice = createSlice({
8989
...payload,
9090
}),
9191
},
92-
extraReducers: {
93-
// [fetchCommonLeaderboard.pending]: state => {
94-
// state.loading = loadingStatuses.LOADING;
95-
// },
96-
// [fetchCommonLeaderboard.fulfilled]: (state, action) => {
97-
// state.loading = loadingStatuses.PENDING;
98-
// state.commonLeaderboard = {
99-
// items: action.payload.items,
100-
// pageNumber: action.payload.pageInfo.pageNumber,
101-
// pageSize: action.payload.pageInfo.pageSize,
102-
// totalEntries: action.payload.pageInfo.totalEntries,
103-
// };
104-
// },
105-
// [fetchCommonLeaderboard.rejected]: state => {
106-
// state.loading = loadingStatuses.PENDING;
107-
// state.commonLeaderboard = {};
108-
// },
92+
extraReducers: builder => {
93+
// builder
94+
// .addCase(fetchCommonLeaderboard.pending, state => {
95+
// state.loading = loadingStatuses.LOADING;
96+
// })
97+
// .addCase(fetchCommonLeaderboard.fulfilled, (state, action) => {
98+
// state.loading = loadingStatuses.PENDING;
99+
// state.commonLeaderboard = {
100+
// items: action.payload.items,
101+
// pageNumber: action.payload.pageInfo.pageNumber,
102+
// pageSize: action.payload.pageInfo.pageSize,
103+
// totalEntries: action.payload.pageInfo.totalEntries,
104+
// };
105+
// })
106+
// .addCase(fetchCommonLeaderboard.rejected, state => {
107+
// state.loading = loadingStatuses.PENDING;
108+
// state.commonLeaderboard = {};
109+
// });
109110
},
110111
});
111112

services/app/apps/codebattle/assets/js/widgets/slices/leaderboard.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,28 @@ const leaderboardSlice = createSlice({
5353
state.period = action.payload;
5454
},
5555
},
56-
extraReducers: {
57-
[fetchUsers.pending]: state => {
58-
if (state.loading === loadingStatuses.IDLE) {
59-
state.loading = loadingStatuses.PENDING;
60-
}
61-
if (state.loading === loadingStatuses.INITIAL) {
62-
state.loading = loadingStatuses.IDLE;
63-
}
64-
},
65-
[fetchUsers.fulfilled]: (state, action) => {
66-
if (state.loading === loadingStatuses.PENDING) {
67-
state.loading = loadingStatuses.IDLE;
68-
state.users = action.payload.users;
69-
}
70-
},
71-
[fetchUsers.rejected]: (state, action) => {
72-
if (state.loading === loadingStatuses.PENDING) {
73-
state.loading = loadingStatuses.IDLE;
74-
state.error = action.error;
75-
}
76-
},
56+
extraReducers: builder => {
57+
builder
58+
.addCase(fetchUsers.pending, state => {
59+
if (state.loading === loadingStatuses.IDLE) {
60+
state.loading = loadingStatuses.PENDING;
61+
}
62+
if (state.loading === loadingStatuses.INITIAL) {
63+
state.loading = loadingStatuses.IDLE;
64+
}
65+
})
66+
.addCase(fetchUsers.fulfilled, (state, action) => {
67+
if (state.loading === loadingStatuses.PENDING) {
68+
state.loading = loadingStatuses.IDLE;
69+
state.users = action.payload.users;
70+
}
71+
})
72+
.addCase(fetchUsers.rejected, (state, action) => {
73+
if (state.loading === loadingStatuses.PENDING) {
74+
state.loading = loadingStatuses.IDLE;
75+
state.error = action.error;
76+
}
77+
});
7778
},
7879
});
7980

services/app/apps/codebattle/assets/js/widgets/slices/lobby.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ const lobby = createSlice({
134134
state.nearbyUsers = payload.users.map(u => u.id);
135135
},
136136
},
137-
extraReducers: {
138-
[tournamentActions.changeTournamentState]: (state, { payload }) => {
137+
extraReducers: builder => {
138+
builder.addCase(tournamentActions.changeTournamentState, (state, { payload }) => {
139139
const seasonTournament = state.seasonTournaments.find(
140140
t => t.id === payload.id,
141141
);
@@ -156,7 +156,7 @@ const lobby = createSlice({
156156
if (liveTournament) {
157157
state.liveTournaments = state.liveTournaments.map(t => (t.id === payload.id ? { ...t, state: payload.state } : t));
158158
}
159-
},
159+
});
160160
},
161161
});
162162

services/app/apps/codebattle/assets/js/widgets/slices/playbook.js

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,34 @@ const playbook = createSlice({
2525
},
2626
changeSolutionType: (state, { payload }) => ({ ...state, solutionType: payload.solutionType }),
2727
},
28-
extraReducers: {
29-
[editorActions.updateEditorText]: (state, { payload }) => {
30-
const { players, records } = addRecord({
31-
...state,
32-
payload,
33-
type: 'update_editor_data',
28+
extraReducers: builder => {
29+
builder
30+
.addCase(editorActions.updateEditorText, (state, { payload }) => {
31+
const { players, records } = addRecord({
32+
...state,
33+
payload,
34+
type: 'update_editor_data',
35+
});
36+
37+
return {
38+
...state,
39+
players,
40+
records,
41+
};
42+
})
43+
.addCase(executionOutputActions.updateExecutionOutput, (state, { payload }) => {
44+
const { players, records } = addRecord({
45+
...state,
46+
payload,
47+
type: 'check_complete',
48+
});
49+
50+
return {
51+
...state,
52+
players,
53+
records,
54+
};
3455
});
35-
36-
return {
37-
...state,
38-
players,
39-
records,
40-
};
41-
},
42-
[executionOutputActions.updateExecutionOutput]: (state, { payload }) => {
43-
const { players, records } = addRecord({
44-
...state,
45-
payload,
46-
type: 'check_complete',
47-
});
48-
49-
return {
50-
...state,
51-
players,
52-
records,
53-
};
54-
},
5556
},
5657
});
5758

services/app/apps/codebattle/lib/codebattle_web/templates/layout/app.html.heex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!DOCTYPE html>
12
<html lang="en">
23
<head>
34
<meta charset="utf-8" />

0 commit comments

Comments
 (0)