Skip to content

Commit b5ea74c

Browse files
committed
refactor: Migration to Reach 2+ & restyling
BREAKING CHANGE: Reach 2+ not compatible with legacy, new default namespace
1 parent 80cd1c2 commit b5ea74c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1715
-1640
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
}
1313
},
1414
"presets": ["es2015", "react", "stage-0"]
15-
}
15+
}

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
# Set default charset
13+
[*.{js,html,json,md}]
14+
charset = utf-8
15+
16+
# Set indent style for JS & html
17+
[{src/**.js,test/**.js,./*.js,samples/*.html}]
18+
indent_style = tab
19+
20+
# Set indent style for conf files
21+
[{package.json,./*.yml}]
22+
indent_style = space
23+
indent_size = 2
24+
25+
# Set indent style for doc
26+
[manual/*.md]
27+
indent_style = space
28+
indent_size = 4

.eslintrc.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@ parser: babel-eslint
22

33
root: true
44

5-
globals:
6-
RTCPeerConnection: true
7-
attachMediaStream: true
8-
Webcom: false
9-
getUserMedia: true
10-
detachMediaStream: true
11-
12-
ecmaFeatures:
13-
modules: true
5+
parserOptions:
6+
ecmaVersion: 6
7+
sourceType: module
8+
ecmaFeatures:
9+
jsx: true
1410

1511
rules:
1612
strict: 0
1713
indent:
1814
- 2
1915
- tab
16+
- SwitchCase: 1
2017
quotes:
2118
- 2
2219
- single
@@ -30,7 +27,7 @@ rules:
3027
- 0
3128
complexity:
3229
- 2
33-
- 5
30+
- 10
3431
max-depth:
3532
- 2
3633
- 3
@@ -46,7 +43,7 @@ rules:
4643
- 2
4744
- 20
4845
require-jsdoc:
49-
- 2
46+
- 1
5047
no-var:
5148
- 2
5249
object-shorthand:
@@ -73,7 +70,7 @@ rules:
7370
- 2
7471
no-else-return:
7572
- 2
76-
no-empty-label:
73+
no-labels:
7774
- 2
7875
no-lone-blocks:
7976
- 2
@@ -103,5 +100,11 @@ env:
103100
es6: true
104101
browser: true
105102
node: true
103+
mocha: true
104+
105+
plugins:
106+
- 'react'
106107

107-
extends: 'eslint:recommended'
108+
extends:
109+
- 'eslint:recommended'
110+
- 'plugin:react/recommended'

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# Samples with Webcom and WebRTC
1+
# Samples with Reach
22

33
[![Build Status](https://travis-ci.org/webcom-components/visio-sample.svg?branch=master)](https://travis-ci.org/webcom-components/visio-sample)
44
[![Code Climate](https://codeclimate.com/github/webcom-components/visio-sample/badges/gpa.svg)](https://codeclimate.com/github/webcom-components/visio-sample)
55
[![Test Coverage](https://codeclimate.com/github/webcom-components/visio-sample/badges/coverage.svg)](https://codeclimate.com/github/webcom-components/visio-sample/coverage)
66
[![devDependency Status](https://david-dm.org/webcom-components/visio-sample/dev-status.svg)](https://david-dm.org/webcom-components/visio-sample#info=devDependencies)
77

8-
Web application with
9-
- Share Audio/video
8+
Web application with
9+
- Share Audio/video
1010
- presence
1111
- invitations
1212
- room with multiple participants
1313

1414
Implemented with :
15+
- [Reach](https://github.com/webcom-components/reach)
1516
- [React](https://facebook.github.io/react/)
1617
- [Redux](http://redux.js.org/)
1718
- [React router](https://github.com/rackt/react-router)
@@ -38,17 +39,17 @@ npm run
3839

3940
To only build visio sample in ./dist folder
4041

41-
*visiowebrtc* is on https://webcom.orange.com
42+
*visioreach* is on https://io.dataysnc.orange.com
4243

4344
```bash
4445
npm run build
4546
```
4647

4748
Optional env variables :
48-
- NAMESPACE : namespace for signalisation. Default is *visiowebrtc*
49-
- WS_SERVER : webcom server url. Default is *https://webcom.orange.com*
49+
- NAMESPACE : namespace for signalisation. Default is *visioreach*
50+
- WS_SERVER : webcom server url. Default is *https://io.datasync.orange.com*
5051
- PUBLIC_PATH : relative path of application. Default is /
51-
52+
5253
## Build and watch out visio sample
5354

5455
To build and launch a web server on port 8080
@@ -58,12 +59,12 @@ npm run serve
5859
```
5960

6061
Optional env variables :
61-
- NAMESPACE : namespace for signalisation. Default is *visiowebrtc*
62-
- WS_SERVER : webcom server url. Default is *https://webcom.orange.com*
62+
- NAMESPACE : namespace for signalisation. Default is *visioreach*
63+
- WS_SERVER : webcom server url. Default is *https://io.datasync.orange.com*
6364
- PUBLIC_PATH : relative path of application. Default is /
6465

6566

66-
## Dev server
67+
## Dev server
6768

6869
To build and launch a dev web server on port 8080
6970

@@ -72,8 +73,8 @@ npm start
7273
```
7374

7475
Optional env variables :
75-
- NAMESPACE : namespace for signalisation. Default is *visiowebrtc*
76-
- WS_SERVER : webcom server url. Default is *https://webcom.orange.com*
76+
- NAMESPACE : namespace for signalisation. Default is *visioreach*
77+
- WS_SERVER : webcom server url. Default is *https://io.datasync.orange.com*
7778
- PUBLIC_PATH : relative path of application. Default is /
7879

7980
## Test
@@ -82,7 +83,7 @@ Optional env variables :
8283
npm test
8384
```
8485

85-
With coverage
86+
With coverage
8687

8788
```bash
8889
npm run test:coverage

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"babel": "^6.5.2",
2222
"babel-cli": "^6.5.1",
2323
"babel-core": "^6.5.2",
24-
"babel-eslint": "^5.0.0",
24+
"babel-eslint": "^6.1.2",
2525
"babel-loader": "^6.2.4",
2626
"babel-plugin-react-transform": "^2.0.0",
2727
"babel-plugin-transform-react-constant-elements": "^6.5.0",
@@ -34,7 +34,8 @@
3434
"chai": "^3.5.0",
3535
"css-loader": "^0.23.1",
3636
"cz-conventional-changelog": "^1.1.5",
37-
"eslint": "^2.2.0",
37+
"eslint": "^3.1.1",
38+
"eslint-plugin-react": "^5.2.2",
3839
"expose-loader": "^0.7.1",
3940
"extract-text-webpack-plugin": "^1.0.1",
4041
"file-loader": "^0.8.5",
@@ -56,8 +57,10 @@
5657
},
5758
"dependencies": {
5859
"bootstrap": "^3.3.6",
60+
"bootstrap-material-design": "^0.5.10",
5961
"jquery": "^2.2.1",
6062
"react": "^0.14.7",
63+
"react-bootstrap": "^0.30.0-rc.2",
6164
"react-dom": "^0.14.7",
6265
"react-redux": "^4.4.0",
6366
"react-router": "^2.0.0",
@@ -71,7 +74,7 @@
7174
"redux-simple-router": "^2.0.4",
7275
"redux-thunk": "^1.0.3",
7376
"webcom": "^1.0.1",
74-
"webcom-reach": "^1.0.4"
77+
"webcom-reach": "^2.0.0"
7578
},
7679
"config": {
7780
"commitizen": {

src/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
<meta charset="utf-8">
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
89
</head>
9-
10+
1011
<body>
1112
<div id="root"></div>
1213
</body>
14+
<script>
15+
$.material.init();
16+
</script>
1317
</html>

src/js/actions/invite.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import {rooms, ref, invites} from '../utils/reach';
2+
import * as roomActions from './room';
3+
import {RECEIVE_INVITATION, INVITATION_SENT, INVITATION_ANSWERED, INVITATION_ARCHIVED} from '../utils/constants';
4+
import {guid} from '../utils';
5+
6+
const archive = () => {
7+
return dispatch => {
8+
const reach = ref();
9+
reach.invites()
10+
.then(_invites => {
11+
_invites.forEach(invite => {
12+
reach.base.child(`_/invites/${reach.current.uid}/${invite.uid}`).remove();
13+
invites.remove(invite);
14+
});
15+
})
16+
.then(() => {
17+
dispatch({
18+
type: INVITATION_ARCHIVED,
19+
data: null
20+
});
21+
});
22+
};
23+
};
24+
25+
const answered = (accept, invitee, info) => {
26+
return (dispatch, getState) => {
27+
rooms.add(info.room);
28+
29+
const alreadyInRoom = getState().room && getState().room.info;
30+
if (!alreadyInRoom && accept) {
31+
dispatch(roomActions.join(info.room));
32+
}
33+
34+
dispatch({
35+
type: INVITATION_ANSWERED,
36+
data: {
37+
accept,
38+
invitee,
39+
info
40+
}
41+
});
42+
};
43+
};
44+
45+
const send = (invitee, room) => {
46+
return (dispatch, getState) => {
47+
Promise.resolve(rooms.find(room))
48+
.then(_room => {
49+
if(!_room) {
50+
return ref()
51+
.createRoom(guid())
52+
.then(_newRoom => {
53+
rooms.add(_newRoom);
54+
return _newRoom;
55+
});
56+
}
57+
return _room;
58+
})
59+
.then(_room => _room.invite([invitee], 'MODERATOR', 'Let\'s chat...'))
60+
.then(_data => {
61+
const
62+
_room = _data.room,
63+
_invite = _data.invites[0];
64+
65+
invites.add(_invite);
66+
67+
dispatch({type: INVITATION_SENT, data: {invitee, room: {..._room}}});
68+
69+
_invite.on('ACCEPTED', invite => {
70+
dispatch(answered(true, invitee, invite, _room));
71+
});
72+
73+
_invite.on('REJECTED', invite => {
74+
dispatch(answered(false, invitee, invite, _room));
75+
});
76+
77+
const alreadyInRoom = getState().room && getState().room.uid;
78+
if (!alreadyInRoom) {
79+
dispatch(roomActions.join(_room));
80+
}
81+
});
82+
};
83+
};
84+
85+
const receive = (sender, invite) => {
86+
invites.add(invite);
87+
return {
88+
type: RECEIVE_INVITATION,
89+
data: {
90+
from: sender.name,
91+
topic: invite.topic,
92+
uid: invite.uid,
93+
room: invite.room
94+
}
95+
};
96+
};
97+
98+
const answer = (accept, invite, reason) => {
99+
return dispatch => {
100+
invites.find(invite)[accept ? 'accept' : 'reject'](reason)
101+
.then(data => {
102+
dispatch(answered(accept, ref().current, data));
103+
});
104+
};
105+
};
106+
107+
108+
export {archive, send, receive, answer, answered};
109+
110+
111+

0 commit comments

Comments
 (0)