Skip to content

Commit 454dfa7

Browse files
committed
Prettier
1 parent fa2f163 commit 454dfa7

File tree

6 files changed

+57
-49
lines changed

6 files changed

+57
-49
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
.wsStatusIcon {
2-
padding: var(--spacing-sm);
2+
padding: var(--spacing-sm);
33
}
44

55
.spin {
6-
animation: spin 1s linear infinite;
6+
animation: spin 1s linear infinite;
77
}
88

99
@keyframes spin {
1010
to {
1111
transform: rotate(360deg);
1212
}
13-
}
13+
}

lego-webapp/components/WebsocketGroupProvider/index.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ChildrenProps = {
1212
connected: boolean;
1313
pending: boolean;
1414
error: boolean;
15-
}
15+
};
1616

1717
type Props = {
1818
group: string;
@@ -21,9 +21,14 @@ type Props = {
2121

2222
const WebsocketGroupProvider = ({ group, children }: Props) => {
2323
const dispatch = useAppDispatch();
24-
const websocketsStatus: WebsocketsStatusType = useAppSelector((state) => state.websockets.status);
25-
const groupStatus = useAppSelector((state) => state.websockets.groups.find(g => g.group === group)?.status) || GROUP_STATUS_PENDING
26-
24+
const websocketsStatus: WebsocketsStatusType = useAppSelector(
25+
(state) => state.websockets.status,
26+
);
27+
const groupStatus =
28+
useAppSelector(
29+
(state) => state.websockets.groups.find((g) => g.group === group)?.status,
30+
) || GROUP_STATUS_PENDING;
31+
2732
useEffect(() => {
2833
if (websocketsStatus.connected && !websocketsStatus.error) {
2934
dispatch({
@@ -58,7 +63,7 @@ const WebsocketGroupProvider = ({ group, children }: Props) => {
5863

5964
return children({
6065
WebsocketStatus: () => <WebsocketsStatusComponent />,
61-
...groupStatus
66+
...groupStatus,
6267
});
6368
};
6469

lego-webapp/redux/actionTypes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ export const FeatureFlag = {
352352
};
353353

354354
export const Websockets = {
355-
CONNECTED: "Websockets.CONNECTED",
356-
CLOSED: "Websockets.CLOSED",
357-
ERROR: "Websockets.ERROR",
355+
CONNECTED: 'Websockets.CONNECTED',
356+
CLOSED: 'Websockets.CLOSED',
357+
ERROR: 'Websockets.ERROR',
358358
GROUP_JOIN: generateStatuses('Websockets.GROUP_JOIN'),
359359
GROUP_LEAVE: generateStatuses('Websockets.GROUP_LEAVE'),
360-
}
360+
};

lego-webapp/redux/middlewares/websocketMiddleware.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ const createWebSocketMiddleware = (): Middleware => {
8888
socket = null;
8989
return next(action);
9090
}
91-
91+
9292
if (socket && socket.readyState === 1) {
9393
switch (action.type) {
9494
case WebsocketsAT.GROUP_JOIN.BEGIN:
9595
case WebsocketsAT.GROUP_LEAVE.BEGIN:
96-
socket.send(JSON.stringify({
97-
type: action.type,
98-
payload: action.payload
99-
}));
96+
socket.send(
97+
JSON.stringify({
98+
type: action.type,
99+
payload: action.payload,
100+
}),
101+
);
100102
}
101103
return next(action);
102104
}

lego-webapp/redux/models/Websockets.d.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
export type Websockets = {
32
status: WebsocketsStatus;
43
groups: WebsocketsGroup[];
@@ -12,13 +11,13 @@ export type WebsocketsStatus = {
1211
export type WebsocketsGroup = {
1312
group: string;
1413
status: WebsocketsGroupStatus;
15-
}
14+
};
1615

1716
export type WebsocketsGroupStatus = {
1817
connected: boolean;
1918
pending: boolean;
2019
error: boolean;
21-
}
20+
};
2221

2322
export type UnknownWebsocket = {
2423
connected?: boolean;
Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
import { createSlice } from "@reduxjs/toolkit";
2-
import { Websockets as WebsocketsAT } from "../actionTypes"
3-
import { Websockets, WebsocketsGroup } from "../models/Websockets";
4-
import { EntityType } from "../models/entities";
1+
import { createSlice } from '@reduxjs/toolkit';
2+
import { Websockets as WebsocketsAT } from '../actionTypes';
3+
import { Websockets, WebsocketsGroup } from '../models/Websockets';
4+
import { EntityType } from '../models/entities';
55

66
const GROUP_STATUS_INITIAL = {
77
connected: false,
88
pending: false,
9-
error: false
10-
}
9+
error: false,
10+
};
1111

1212
export const GROUP_STATUS_PENDING = {
1313
...GROUP_STATUS_INITIAL,
1414
pending: true,
15-
}
15+
};
1616

1717
const GROUP_STATUS_CONNECTED = {
1818
...GROUP_STATUS_INITIAL,
1919
connected: true,
20-
}
20+
};
2121

2222
export const GROUP_STATUS_ERROR = {
2323
...GROUP_STATUS_INITIAL,
24-
error: true
25-
}
24+
error: true,
25+
};
2626

2727
const initialState: Websockets = {
2828
status: {
2929
connected: false,
30-
error: false
30+
error: false,
3131
},
3232
groups: [] as WebsocketsGroup[],
3333
};
@@ -50,31 +50,33 @@ const websocketsSlice = createSlice({
5050
if (!setGroupStatus(state, action, GROUP_STATUS_PENDING))
5151
state.groups.push({
5252
group: action.payload.group,
53-
status: GROUP_STATUS_PENDING
54-
})
55-
})
53+
status: GROUP_STATUS_PENDING,
54+
});
55+
});
5656
addCase(WebsocketsAT.GROUP_JOIN.SUCCESS, (state, action) => {
57-
setGroupStatus(state, action, GROUP_STATUS_CONNECTED)
58-
})
57+
setGroupStatus(state, action, GROUP_STATUS_CONNECTED);
58+
});
5959
addCase(WebsocketsAT.GROUP_JOIN.FAILURE, (state, action) => {
60-
setGroupStatus(state, action, GROUP_STATUS_ERROR)
61-
})
60+
setGroupStatus(state, action, GROUP_STATUS_ERROR);
61+
});
6262
addCase(WebsocketsAT.GROUP_LEAVE.BEGIN, (state, action) => {
63-
setGroupStatus(state, action, GROUP_STATUS_PENDING)
64-
})
63+
setGroupStatus(state, action, GROUP_STATUS_PENDING);
64+
});
6565
addCase(WebsocketsAT.GROUP_LEAVE.SUCCESS, (state, action) => {
66-
setGroupStatus(state, action, GROUP_STATUS_INITIAL)
67-
})
68-
},
66+
setGroupStatus(state, action, GROUP_STATUS_INITIAL);
67+
});
68+
},
6969
});
7070

7171
const setGroupStatus = (state, action, status): boolean => {
72-
const group = state.groups.find(item => item.group === action.payload.group)
72+
const group = state.groups.find(
73+
(item) => item.group === action.payload.group,
74+
);
7375
if (group) {
74-
group.status = status
75-
return true
76+
group.status = status;
77+
return true;
7678
}
77-
return false
78-
}
79+
return false;
80+
};
7981

80-
export default websocketsSlice.reducer;
82+
export default websocketsSlice.reducer;

0 commit comments

Comments
 (0)