1
1
import React from 'react' ;
2
- import ReactMarkdown from 'react-markdown' ;
3
2
import { connect , useDispatch } from 'react-redux' ;
4
3
import { Link } from 'react-router-dom' ;
5
4
import PropTypes from 'prop-types' ;
@@ -15,15 +14,14 @@ import Button from '@material-ui/core/Button';
15
14
import Alert from '@material-ui/lab/Alert' ;
16
15
import ListSubheader from '@material-ui/core/ListSubheader' ;
17
16
import AddIcon from '@material-ui/icons/Add' ;
18
- // import AddRoomDialog from './AddRoomDialog';
19
- import RoomConfigureDialog from './RoomConfigureDialog' ;
20
- import RoomListItem from './RoomListItem' ;
21
- import EventListItem from './common/EventListItem' ;
22
- import LobbyUserList from './LobbyUserList' ;
23
- import { lcFetch } from '../lib/fetch' ;
24
- import { createRoom } from '../store/rooms/actions' ;
17
+ import RoomConfigureDialog from '../RoomConfigureDialog' ;
18
+ import RoomListItem from '../RoomListItem' ;
19
+ import EventListItem from '../common/EventListItem' ;
20
+ import UserList from './UserList' ;
21
+ import Announcements from './Announcements' ;
22
+ import { createRoom } from '../../store/rooms/actions' ;
25
23
26
- /**
24
+ /**-
27
25
* Lobby:
28
26
* Has 2 parts: room list and user list
29
27
* should render with tabs on mobile like the Room page
@@ -69,11 +67,6 @@ const useStyles = makeStyles((theme) => ({
69
67
backgroundColor : theme . palette . primary . dark ,
70
68
} ,
71
69
} ,
72
- announcements : {
73
- padding : '1em' ,
74
- marginTop : '1em' ,
75
- marginBottom : '1em' ,
76
- } ,
77
70
userList : {
78
71
display : 'flex' ,
79
72
flexDirection : 'column' ,
@@ -174,7 +167,6 @@ function Lobby({
174
167
const classes = useStyles ( ) ;
175
168
const dispatch = useDispatch ( ) ;
176
169
const [ createRoomDialogOpen , setCreateRoomDialogOpen ] = React . useState ( false ) ;
177
- const [ announcements , setAnnouncements ] = React . useState ( '' ) ;
178
170
const events = rooms . filter ( ( room ) => room . type !== 'normal' ) ;
179
171
const publicRooms = rooms . filter ( ( room ) => ! room . private && room . type === 'normal' ) ;
180
172
const privateRooms = rooms . filter ( ( room ) => ! ! room . private && room . type === 'normal' ) ;
@@ -184,22 +176,6 @@ function Lobby({
184
176
dispatch ( createRoom ( options ) ) ;
185
177
} ;
186
178
187
- React . useEffect ( ( ) => {
188
- lcFetch ( '/api/announcements' )
189
- . then ( ( data ) => {
190
- if ( ! data . ok ) {
191
- throw new Error ( ) ;
192
- }
193
- return data . text ( ) ;
194
- } )
195
- . then ( ( data ) => {
196
- setAnnouncements ( data ) ;
197
- } )
198
- . catch ( ( err ) => {
199
- throw err ;
200
- } ) ;
201
- } , [ ] ) ;
202
-
203
179
return (
204
180
< div className = { classes . root } >
205
181
< Grid
@@ -218,14 +194,7 @@ function Lobby({
218
194
maxWidth = "md"
219
195
disableGutters
220
196
>
221
- { announcements && (
222
- < Paper className = { classes . announcements } >
223
- < ReactMarkdown
224
- linkTarget = "_blank"
225
- source = { announcements }
226
- />
227
- </ Paper >
228
- ) }
197
+ < Announcements />
229
198
{ showAlert && (
230
199
< Alert
231
200
className = { classes . alert }
@@ -271,22 +240,6 @@ function Lobby({
271
240
</ div >
272
241
273
242
< Paper >
274
- < List subheader = { < ListSubheader > Public Rooms</ ListSubheader > } >
275
- { publicRooms . map ( ( room ) => (
276
- < RoomListItem
277
- key = { room . _id }
278
- room = { room }
279
- />
280
- ) ) }
281
- </ List >
282
- < List subheader = { < ListSubheader > Public Rooms</ ListSubheader > } >
283
- { publicRooms . map ( ( room ) => (
284
- < RoomListItem
285
- key = { room . _id }
286
- room = { room }
287
- />
288
- ) ) }
289
- </ List >
290
243
< List subheader = { < ListSubheader > Public Rooms</ ListSubheader > } >
291
244
{ publicRooms . map ( ( room ) => (
292
245
< RoomListItem
@@ -309,7 +262,7 @@ function Lobby({
309
262
</ div >
310
263
</ Grid >
311
264
< Grid item xs = { 3 } className = { classes . userList } >
312
- < LobbyUserList users = { USERS } />
265
+ < UserList users = { USERS } />
313
266
</ Grid >
314
267
</ Grid >
315
268
< RoomConfigureDialog
0 commit comments