Skip to content

Commit 881e215

Browse files
committed
Fixed meeting bug and added singleton.
1 parent 7ac3df9 commit 881e215

File tree

17 files changed

+232
-51
lines changed

17 files changed

+232
-51
lines changed

meetsy/package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

meetsy/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
"react-dom": "^17.0.2",
3232
"react-jss": "^10.6.0",
3333
"react-loading-screen": "0.0.17",
34+
"react-modal": "^3.14.2",
3435
"react-router-dom": "^5.2.0",
3536
"react-scripts": "4.0.3",
37+
"reactjs-popup": "^2.0.4",
3638
"recompose": "^0.30.0",
3739
"run-p": "0.0.0",
3840
"simple-flexbox": "^2.3.2",

meetsy/src/components/App/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import TeamComponent from '../Team/TeamComponent';
2626
import TeamCollection from '../Team/TeamCollection';
2727
import {compose} from 'recompose';
2828
import LoadingScreen from 'react-loading-screen';
29+
import CallError from '../CallError';
2930
const styles = StyleSheet.create({
3031

3132
content: {
@@ -116,6 +117,7 @@ class App extends Component {
116117
<Route path={ROUTES.USERS} component={UserList} />
117118
<Route path={ROUTES.USER_DETAILS} component={UserItem} />
118119
<Route path={ROUTES.SHOW_TEAMS} component={TeamCollection}/>
120+
<Route path={ROUTES.CALLERROR} component={CallError}/>
119121
<Route path="/meet/:url" component={Meet} />
120122
<Route path="/showteam/:teamId" component={TeamComponent} />
121123
{/* <Route path={ROUTES.TEAM} component={TeamComponent}/> */}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from 'react';
2+
import { Component } from 'react';
3+
import { withAuthorization } from '../Session';
4+
import { withFirebase } from '../Firebase';
5+
import {compose} from 'recompose';
6+
import { COLORS } from '../../constants/designConstants';
7+
import styled from 'styled-components';
8+
import {withRouter} from 'react-router-dom';
9+
import * as ROUTES from '../../constants/routes';
10+
class Error extends Component {
11+
constructor(props){
12+
super(props);
13+
14+
}
15+
16+
render() {
17+
18+
return (
19+
20+
<div style={{position:'relative', marginLeft: 'auto', marginRight: 'auto', marginTop:'auto', marginBottom: 'auto'}}>
21+
<h1>Error 101 - Hey, you little troublemaker...</h1>
22+
<p>Seems like you are already in that call. Press the button below to return home.
23+
</p>
24+
<StyledButton onClick = {() => this.props.history.push(ROUTES.HOME)}>Home</StyledButton>
25+
26+
27+
</div>
28+
29+
)
30+
}
31+
}
32+
33+
const StyledButton = styled.button`
34+
margin-left:auto;
35+
margin-right:auto;
36+
max-width: 250px;
37+
min-width: 150px;
38+
height: 40px;
39+
border: none;
40+
margin: 1rem 0;
41+
box-shadow: 0px 14px 9 px -15px rgba(0,0,0,0.25);
42+
border-radius: 32px;
43+
background-color: ${COLORS.primaryBlue};
44+
color: white;
45+
font-weight: 600;
46+
cursor: pointer;
47+
align-self: center;
48+
&:hover {
49+
background-color: ${COLORS.primaryBlue};
50+
}
51+
`;
52+
const condition = authUser => !!authUser;
53+
export default compose(withRouter, withAuthorization(condition))(Error);

meetsy/src/components/Firebase/firebase.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ const firebaseConfig = {
2626
// firebase.initializeApp(firebaseConfig);
2727

2828

29-
class Firebase {
29+
var SingletonFactory = (function() {
30+
31+
class Firebase {
3032
constructor() {
3133
firebase.initializeApp(firebaseConfig);
3234

@@ -79,5 +81,15 @@ class Firebase {
7981
teams = () => this.db.collection('teams');
8082

8183
}
82-
83-
export default Firebase;
84+
var instance;
85+
return {
86+
getInstance: function(){
87+
if(!instance){
88+
instance = new Firebase();
89+
delete instance.constructor;
90+
}
91+
return instance;
92+
}
93+
}
94+
})();
95+
export default SingletonFactory;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Firebase from './firebase';
1+
import SingletonFactory from './firebase';
22
import FirebaseContext, { withFirebase } from './context';
33

4-
export default Firebase;
4+
export default SingletonFactory;
55
export { FirebaseContext, withFirebase };

meetsy/src/components/Home/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ class Home extends Component {
88
constructor(props){
99
super(props);
1010
}
11+
1112
render() {
13+
1214
return (
1315
<div>
1416
<h1>Welcome back, {this.props.firebase.authUser.username}</h1>
1517
<p>The Home Page is accessible by every signed in user.</p>
18+
1619
</div>
1720
)
1821
}
1922
}
20-
2123
const condition = authUser => !!authUser;
2224
export default compose (withFirebase, withAuthorization(condition))(Home);

meetsy/src/components/Meet/MeetItem

Whitespace-only changes.

meetsy/src/components/Meet/index.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import ScreenShareIcon from '@material-ui/icons/ScreenShare'
1313
import StopScreenShareIcon from '@material-ui/icons/StopScreenShare'
1414
import CallEndIcon from '@material-ui/icons/CallEnd'
1515
import ChatIcon from '@material-ui/icons/Chat'
16-
16+
import { withFirebase } from '../Firebase';
1717
import { message } from 'antd'
1818
import 'antd/dist/antd.css'
19+
import {compose} from 'recompose';
1920

2021
import { Row } from 'simple-flexbox'
2122
import Modal from 'react-bootstrap/Modal'
@@ -54,7 +55,9 @@ class Meet extends Component {
5455
message: "",
5556
newmessages: 0,
5657
askForUsername: true,
57-
username: faker.internet.userName(),
58+
username: this.props.firebase.authUser.username,
59+
userId: this.props.firebase.authUser.userId
60+
5861
}
5962
connections = {}
6063

@@ -278,13 +281,18 @@ class Meet extends Component {
278281
socket.on("connect_error", (err) => {
279282
console.log(`connect_error due to ${err.message}`);
280283
});
284+
281285
socket.on('signal', this.gotMessageFromServer)
282286

283287
socket.on('connect', () => {
284288
console.log('S-a realizat conexiunea!')
285-
socket.emit('join-call', window.location.href)
289+
console.log("Id: ", this.state.userId);
290+
socket.emit('join-call', window.location.href, this.state.userId)
286291
socketId = socket.id
287292

293+
socket.on("already-in-call-error", () => {
294+
window.location.href = ROUTES.CALLERROR;
295+
})
288296
socket.on('chat-message', this.addMessage)
289297

290298
socket.on('user-left', (id) => {
@@ -299,7 +307,6 @@ class Meet extends Component {
299307
})
300308

301309
socket.on('user-joined', (id, clients) => {
302-
console.log('User-ul a intrat!')
303310
clients.forEach((socketListId) => {
304311
connections[socketListId] = new RTCPeerConnection(peerConnectionConfig)
305312
// Wait for their ice candidate
@@ -324,7 +331,7 @@ class Meet extends Component {
324331

325332
let css = {
326333
minWidth: cssMesure.minWidth, minHeight: cssMesure.minHeight, maxHeight: "100%", margin: "10px",
327-
borderStyle: "solid", borderRadius: "25px", objectFit: "cover"
334+
borderStyle: "solid", borderRadius: "15px", objectFit: "cover"
328335
}
329336
for (let i in css) video.style[i] = css[i]
330337

@@ -484,7 +491,7 @@ class Meet extends Component {
484491

485492
<div style={{ justifyContent: "center", textAlign: "center", paddingTop: "40px" }}>
486493
<video id="my-video" ref={this.localVideoref} autoPlay muted style={{
487-
borderStyle: "solid", borderColor: "#bdbdbd", objectFit: "fill", width: "60%", height: "30%"
494+
borderStyle: "solid", borderRadius: "15px", borderColor: "#bdbdbd", objectFit: "fill", width: "60%", height: "30%"
488495
}}></video>
489496
</div>
490497
</div>
@@ -549,7 +556,7 @@ class Meet extends Component {
549556

550557
<Row id="main" className="flex-container" style={{ margin: 0, padding: 0 }}>
551558
<video id="my-video" ref={this.localVideoref} autoPlay muted style={{
552-
borderStyle: "solid", borderRadius: "25px", margin: "10px", objectFit: "cover",
559+
borderStyle: "solid", borderRadius: "15px", margin: "10px", objectFit: "cover",
553560
width: "100%", height: "100%"
554561
}}></video>
555562
{/*
@@ -574,4 +581,4 @@ class Meet extends Component {
574581
}
575582

576583
const condition = authUser => !!authUser;
577-
export default withAuthorization(condition)(Meet);
584+
export default compose(withFirebase, withAuthorization(condition))(Meet);

meetsy/src/components/Meet/meet.css

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@ body {
44
p{
55
color: black;
66
}
7+
canvas {
8+
background-color: blue !important;
9+
}
710

811
.flex-container {
9-
height: calc(100% - 150px);
12+
height:calc(100vh - 300px);
1013
width: 100%;
1114
/* margin: 0 auto; */
1215
display: flex;
1316
flex-direction: row;
1417
align-items: center;
18+
flex-wrap: wrap !important;
1519
justify-content: center;
1620
}
1721

1822
.container {
19-
height: 60vh;
20-
width: 60vw;
21-
max-width: 60vw;
23+
height: 100%;
24+
width: 100%;
2225
max-height: 60vh;
2326

2427
align-items: center;

0 commit comments

Comments
 (0)