瀏覽代碼

Move ConferenceUrl.inviteURL into React and redux

master
Lyubo Marinov 8 年之前
父節點
當前提交
ec454d1da0

+ 2
- 2
lang/main.json 查看文件

435
     "invite": {
435
     "invite": {
436
         "addPassword": "Add password",
436
         "addPassword": "Add password",
437
         "callNumber": "Call __number__",
437
         "callNumber": "Call __number__",
438
-        "enterId": "Enter Meeting ID: __meetingId__ following by # to dial in from a phone",
438
+        "enterID": "Enter Meeting ID: __conferenceID__ following by # to dial in from a phone",
439
         "howToDialIn": "To dial in, use one of the following numbers and meeting ID",
439
         "howToDialIn": "To dial in, use one of the following numbers and meeting ID",
440
         "hidePassword": "Hide password",
440
         "hidePassword": "Hide password",
441
         "inviteTo": "Invite people to __conferenceName__",
441
         "inviteTo": "Invite people to __conferenceName__",
442
-        "invitedYouTo": "__userName__ has invited you to the __meetingUrl__ conference",
442
+        "invitedYouTo": "__userName__ has invited you to the __inviteURL__ conference",
443
         "locked": "This call is locked. New callers must have the link and enter the password to join.",
443
         "locked": "This call is locked. New callers must have the link and enter the password to join.",
444
         "showPassword": "Show password",
444
         "showPassword": "Show password",
445
         "unlocked": "This call is unlocked. Any new caller with the link may join the call."
445
         "unlocked": "This call is unlocked. Any new caller with the link may join the call."

+ 3
- 18
modules/URL/ConferenceUrl.js 查看文件

24
      * from the sample URL.
24
      * from the sample URL.
25
      */
25
      */
26
     constructor(location) {
26
     constructor(location) {
27
-        /**
28
-         * A simplified version of the conference URL stripped out of
29
-         * the parameters which should be used for sending invites.
30
-         * Example:
31
-         * https://example.com:8888/SomeConference1245
32
-         * @type {string}
33
-         */
34
-        this.inviteURL
35
-            = location.protocol + "//" + location.host + location.pathname;
36
         logger.info("Stored original conference URL: " + location.href);
27
         logger.info("Stored original conference URL: " + location.href);
37
-        logger.info("Conference URL for invites: " + this.inviteURL);
38
-    }
39
-    /**
40
-     * Obtains the conference invite URL.
41
-     * @return {string} the URL pointing o the conference which is mean to be
42
-     * used to invite new participants.
43
-     */
44
-    getInviteUrl() {
45
-        return this.inviteURL;
28
+        logger.info(
29
+                "Conference URL for invites: " + location.protocol + "//"
30
+                    + location.host + location.pathname);
46
     }
31
     }
47
 }
32
 }

+ 2
- 3
react/features/base/conference/actions.js 查看文件

121
  * @returns {void}
121
  * @returns {void}
122
  */
122
  */
123
 function _setLocalParticipantData(conference, state) {
123
 function _setLocalParticipantData(conference, state) {
124
-    const localParticipant
125
-        = getLocalParticipant(state['features/base/participants']);
124
+    const { avatarID } = getLocalParticipant(state);
126
 
125
 
127
     conference.removeCommand(AVATAR_ID_COMMAND);
126
     conference.removeCommand(AVATAR_ID_COMMAND);
128
     conference.sendCommand(AVATAR_ID_COMMAND, {
127
     conference.sendCommand(AVATAR_ID_COMMAND, {
129
-        value: localParticipant.avatarID
128
+        value: avatarID
130
     });
129
     });
131
 }
130
 }
132
 
131
 

+ 26
- 0
react/features/base/connection/functions.js 查看文件

1
+/* @flow */
2
+
3
+/**
4
+ * Retrieves a simplified version of the conference/location URL stripped of URL
5
+ * params (i.e. query/search and hash) which should be used for sending invites.
6
+ *
7
+ * @param {Function|Object} stateOrGetState - The redux state or redux's
8
+ * {@code getState} function.
9
+ * @returns {string|undefined}
10
+ */
11
+export function getInviteURL(stateOrGetState: Function | Object): ?string {
12
+    const state
13
+        = typeof stateOrGetState === 'function'
14
+            ? stateOrGetState()
15
+            : stateOrGetState;
16
+    const { locationURL } = state['features/base/connection'];
17
+    let inviteURL;
18
+
19
+    if (locationURL) {
20
+        const { host, pathname, protocol } = locationURL;
21
+
22
+        inviteURL = `${protocol}//${host}${pathname}`;
23
+    }
24
+
25
+    return inviteURL;
26
+}

+ 1
- 0
react/features/base/connection/index.js 查看文件

1
 export * from './actions';
1
 export * from './actions';
2
 export * from './actionTypes';
2
 export * from './actionTypes';
3
+export * from './functions';
3
 
4
 
4
 import './reducer';
5
 import './reducer';

+ 26
- 19
react/features/base/participants/functions.js 查看文件

69
 /**
69
 /**
70
  * Returns local participant from Redux state.
70
  * Returns local participant from Redux state.
71
  *
71
  *
72
- * @param {(Function|Participant[])} participantsOrGetState - Either the
73
- * features/base/participants Redux state or Redux's getState function to be
74
- * used to retrieve the features/base/participants state.
72
+ * @param {(Function|Object|Participant[])} stateOrGetState - The redux state
73
+ * features/base/participants, the (whole) redux state, or redux's
74
+ * {@code getState} function to be used to retrieve the
75
+ * features/base/participants state.
75
  * @returns {(Participant|undefined)}
76
  * @returns {(Participant|undefined)}
76
  */
77
  */
77
-export function getLocalParticipant(participantsOrGetState) {
78
-    const participants = _getParticipants(participantsOrGetState);
78
+export function getLocalParticipant(stateOrGetState) {
79
+    const participants = _getParticipants(stateOrGetState);
79
 
80
 
80
     return participants.find(p => p.local);
81
     return participants.find(p => p.local);
81
 }
82
 }
83
 /**
84
 /**
84
  * Returns participant by ID from Redux state.
85
  * Returns participant by ID from Redux state.
85
  *
86
  *
86
- * @param {(Function|Participant[])} participantsOrGetState - Either the
87
- * features/base/participants Redux state or Redux's getState function to be
88
- * used to retrieve the features/base/participants state.
87
+ * @param {(Function|Object|Participant[])} stateOrGetState - The redux state
88
+ * features/base/participants, the (whole) redux state, or redux's
89
+ * {@code getState} function to be used to retrieve the
90
+ * features/base/participants state.
89
  * @param {string} id - The ID of the participant to retrieve.
91
  * @param {string} id - The ID of the participant to retrieve.
90
  * @private
92
  * @private
91
  * @returns {(Participant|undefined)}
93
  * @returns {(Participant|undefined)}
92
  */
94
  */
93
-export function getParticipantById(participantsOrGetState, id) {
94
-    const participants = _getParticipants(participantsOrGetState);
95
+export function getParticipantById(stateOrGetState, id) {
96
+    const participants = _getParticipants(stateOrGetState);
95
 
97
 
96
     return participants.find(p => p.id === id);
98
     return participants.find(p => p.id === id);
97
 }
99
 }
99
 /**
101
 /**
100
  * Returns array of participants from Redux state.
102
  * Returns array of participants from Redux state.
101
  *
103
  *
102
- * @param {(Function|Participant[])} participantsOrGetState - Either the
103
- * features/base/participants Redux state or Redux's getState function to be
104
- * used to retrieve the features/base/participants state.
104
+ * @param {(Function|Object|Participant[])} stateOrGetState - The redux state
105
+ * features/base/participants, the (whole) redux state, or redux's
106
+ * {@code getState} function to be used to retrieve the
107
+ * features/base/participants state.
105
  * @private
108
  * @private
106
  * @returns {Participant[]}
109
  * @returns {Participant[]}
107
  */
110
  */
108
-function _getParticipants(participantsOrGetState) {
109
-    const participants
110
-        = typeof participantsOrGetState === 'function'
111
-            ? participantsOrGetState()['features/base/participants']
112
-            : participantsOrGetState;
111
+function _getParticipants(stateOrGetState) {
112
+    if (Array.isArray(stateOrGetState)) {
113
+        return stateOrGetState;
114
+    }
115
+
116
+    const state
117
+        = typeof stateOrGetState === 'function'
118
+            ? stateOrGetState()
119
+            : stateOrGetState;
113
 
120
 
114
-    return participants || [];
121
+    return state['features/base/participants'] || [];
115
 }
122
 }

+ 2
- 1
react/features/invite/actionTypes.js 查看文件

16
  *
16
  *
17
  * {
17
  * {
18
  *     type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
18
  *     type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
19
- *     response: Object
19
+ *     conferenceID: Object,
20
+ *     dialInNumbers: Object
20
  * }
21
  * }
21
  */
22
  */
22
 export const UPDATE_DIAL_IN_NUMBERS_SUCCESS
23
 export const UPDATE_DIAL_IN_NUMBERS_SUCCESS

+ 26
- 27
react/features/invite/actions.js 查看文件

15
  * @returns {Function}
15
  * @returns {Function}
16
  */
16
  */
17
 export function openInviteDialog() {
17
 export function openInviteDialog() {
18
-    return openDialog(InviteDialog, {
19
-        conferenceUrl: encodeURI(APP.ConferenceUrl.getInviteUrl())
20
-    });
18
+    return openDialog(InviteDialog);
21
 }
19
 }
22
 
20
 
23
 /**
21
 /**
24
- * Sends an ajax requests for dial-in numbers and conference id.
22
+ * Sends AJAX requests for dial-in numbers and conference ID.
25
  *
23
  *
26
  * @returns {Function}
24
  * @returns {Function}
27
  */
25
  */
28
 export function updateDialInNumbers() {
26
 export function updateDialInNumbers() {
29
     return (dispatch, getState) => {
27
     return (dispatch, getState) => {
28
+        const state = getState();
30
         const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
29
         const { dialInConfCodeUrl, dialInNumbersUrl, hosts }
31
-            = getState()['features/base/config'];
32
-        const mucUrl = hosts && hosts.muc;
30
+            = state['features/base/config'];
31
+        const mucURL = hosts && hosts.muc;
33
 
32
 
34
-        if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucUrl) {
33
+        if (!dialInConfCodeUrl || !dialInNumbersUrl || !mucURL) {
35
             dispatch({
34
             dispatch({
36
                 type: UPDATE_DIAL_IN_NUMBERS_FAILED,
35
                 type: UPDATE_DIAL_IN_NUMBERS_FAILED,
37
                 error: 'URLs for fetching dial in numbers not properly defined'
36
                 error: 'URLs for fetching dial in numbers not properly defined'
40
             return;
39
             return;
41
         }
40
         }
42
 
41
 
43
-        const { room } = getState()['features/base/conference'];
44
-        const conferenceIdUrl
45
-            = `${dialInConfCodeUrl}?conference=${room}@${mucUrl}`;
42
+        const { room } = state['features/base/conference'];
43
+        const conferenceIDURL
44
+            = `${dialInConfCodeUrl}?conference=${room}@${mucURL}`;
46
 
45
 
47
         Promise.all([
46
         Promise.all([
48
             $.getJSON(dialInNumbersUrl),
47
             $.getJSON(dialInNumbersUrl),
49
-            $.getJSON(conferenceIdUrl)
50
-        ]).then(([ numbersResponse, idResponse ]) => {
51
-            if (!idResponse.conference || !idResponse.id) {
52
-                return Promise.reject(idResponse.message);
53
-            }
48
+            $.getJSON(conferenceIDURL)
49
+        ])
50
+            .then(([ dialInNumbers, { conference, id, message } ]) => {
51
+                if (!conference || !id) {
52
+                    return Promise.reject(message);
53
+                }
54
 
54
 
55
-            dispatch({
56
-                type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
57
-                conferenceId: idResponse,
58
-                dialInNumbers: numbersResponse
55
+                dispatch({
56
+                    type: UPDATE_DIAL_IN_NUMBERS_SUCCESS,
57
+                    conferenceID: id,
58
+                    dialInNumbers
59
+                });
60
+            })
61
+            .catch(error => {
62
+                dispatch({
63
+                    type: UPDATE_DIAL_IN_NUMBERS_FAILED,
64
+                    error
65
+                });
59
             });
66
             });
60
-        })
61
-        .catch(error => {
62
-            dispatch({
63
-                type: UPDATE_DIAL_IN_NUMBERS_FAILED,
64
-                error
65
-            });
66
-        });
67
-
68
     };
67
     };
69
 }
68
 }

+ 21
- 20
react/features/invite/components/DialInNumbersForm.js 查看文件

35
         _localUserDisplayName: React.PropTypes.string,
35
         _localUserDisplayName: React.PropTypes.string,
36
 
36
 
37
         /**
37
         /**
38
-         * The url for the JitsiConference.
38
+         * Invoked to send an ajax request for dial-in numbers.
39
          */
39
          */
40
-        conferenceUrl: React.PropTypes.string,
40
+        dispatch: React.PropTypes.func,
41
 
41
 
42
         /**
42
         /**
43
-         * Invoked to send an ajax request for dial-in numbers.
43
+         * The URL of the conference into which this {@code DialInNumbersForm}
44
+         * is inviting the local participant.
44
          */
45
          */
45
-        dispatch: React.PropTypes.func,
46
+        inviteURL: React.PropTypes.string,
46
 
47
 
47
         /**
48
         /**
48
          * Invoked to obtain translated strings.
49
          * Invoked to obtain translated strings.
134
      */
135
      */
135
     render() {
136
     render() {
136
         const { _dialIn, t } = this.props;
137
         const { _dialIn, t } = this.props;
137
-        const { conferenceId, numbers, numbersEnabled } = _dialIn;
138
+        const { conferenceID, numbers, numbersEnabled } = _dialIn;
138
         const { selectedNumber } = this.state;
139
         const { selectedNumber } = this.state;
139
 
140
 
140
-        if (!conferenceId || !numbers || !numbersEnabled || !selectedNumber) {
141
+        if (!conferenceID || !numbers || !numbersEnabled || !selectedNumber) {
141
             return null;
142
             return null;
142
         }
143
         }
143
 
144
 
144
-        const items = numbers ? this._formatNumbers(numbers) : [];
145
+        const items = this._formatNumbers(numbers);
145
 
146
 
146
         return (
147
         return (
147
             <div className = 'form-control dial-in-numbers'>
148
             <div className = 'form-control dial-in-numbers'>
148
                 <label className = 'form-control__label'>
149
                 <label className = 'form-control__label'>
149
                     { t('invite.howToDialIn') }
150
                     { t('invite.howToDialIn') }
150
                     <span className = 'dial-in-numbers-conference-id'>
151
                     <span className = 'dial-in-numbers-conference-id'>
151
-                        { conferenceId }
152
+                        { conferenceID }
152
                     </span>
153
                     </span>
153
                 </label>
154
                 </label>
154
                 <div className = 'form-control__container'>
155
                 <div className = 'form-control__container'>
290
      * @returns {string}
291
      * @returns {string}
291
      */
292
      */
292
     _generateCopyText() {
293
     _generateCopyText() {
293
-        const welcome = this.props.t('invite.invitedYouTo', {
294
-            meetingUrl: this.props.conferenceUrl,
294
+        const { t } = this.props;
295
+        const welcome = t('invite.invitedYouTo', {
296
+            inviteURL: this.props.inviteURL,
295
             userName: this.props._localUserDisplayName
297
             userName: this.props._localUserDisplayName
296
         });
298
         });
297
 
299
 
298
-        const callNumber = this.props.t('invite.callNumber',
299
-            { number: this.state.selectedNumber.number });
300
+        const callNumber = t('invite.callNumber', {
301
+            number: this.state.selectedNumber.number
302
+        });
300
         const stepOne = `1) ${callNumber}`;
303
         const stepOne = `1) ${callNumber}`;
301
 
304
 
302
-        const enterId = this.props.t('invite.enterId',
303
-            { meetingId: this.props._dialIn.conferenceId });
304
-        const stepTwo = `2) ${enterId}`;
305
+        const enterID = t('invite.enterID', {
306
+            conferenceID: this.props._dialIn.conferenceID
307
+        });
308
+        const stepTwo = `2) ${enterID}`;
305
 
309
 
306
         return `${welcome}\n${stepOne}\n${stepTwo}`;
310
         return `${welcome}\n${stepOne}\n${stepTwo}`;
307
     }
311
     }
395
  * }}
399
  * }}
396
  */
400
  */
397
 function _mapStateToProps(state) {
401
 function _mapStateToProps(state) {
398
-    const { name }
399
-        = getLocalParticipant(state['features/base/participants']);
400
-
401
     return {
402
     return {
402
-        _localUserDisplayName: name,
403
-        _dialIn: state['features/invite/dial-in']
403
+        _localUserDisplayName: getLocalParticipant(state).name,
404
+        _dialIn: state['features/invite']
404
     };
405
     };
405
 }
406
 }
406
 
407
 

+ 13
- 15
react/features/invite/components/InviteDialog.js 查看文件

1
 import React, { Component } from 'react';
1
 import React, { Component } from 'react';
2
 import { connect } from 'react-redux';
2
 import { connect } from 'react-redux';
3
 
3
 
4
+import { getInviteURL } from '../../base/connection';
4
 import { Dialog } from '../../base/dialog';
5
 import { Dialog } from '../../base/dialog';
5
 import { translate } from '../../base/i18n';
6
 import { translate } from '../../base/i18n';
6
 import JitsiMeetJS from '../../base/lib-jitsi-meet';
7
 import JitsiMeetJS from '../../base/lib-jitsi-meet';
24
     static propTypes = {
25
     static propTypes = {
25
         /**
26
         /**
26
          * The redux store representation of the JitsiConference.
27
          * The redux store representation of the JitsiConference.
27
-         *
28
          */
28
          */
29
         _conference: React.PropTypes.object,
29
         _conference: React.PropTypes.object,
30
 
30
 
31
         /**
31
         /**
32
-         * Whether or not the current user is a conference moderator.
32
+         * The url for the JitsiConference.
33
          */
33
          */
34
-        _isModerator: React.PropTypes.bool,
34
+        _inviteURL: React.PropTypes.string,
35
 
35
 
36
         /**
36
         /**
37
-         * The url for the JitsiConference.
37
+         * Whether or not the current user is a conference moderator.
38
          */
38
          */
39
-        conferenceUrl: React.PropTypes.string,
39
+        _isModerator: React.PropTypes.bool,
40
 
40
 
41
         /**
41
         /**
42
          * Invoked to obtain translated strings.
42
          * Invoked to obtain translated strings.
60
      * @returns {ReactElement}
60
      * @returns {ReactElement}
61
      */
61
      */
62
     render() {
62
     render() {
63
-        const { _conference, conferenceUrl } = this.props;
63
+        const { _conference, _inviteURL, t } = this.props;
64
         const titleString
64
         const titleString
65
-            = this.props.t(
66
-                'invite.inviteTo',
67
-                { conferenceName: _conference.room });
65
+            = t('invite.inviteTo', { conferenceName: _conference.room });
68
 
66
 
69
         return (
67
         return (
70
             <Dialog
68
             <Dialog
72
                 okTitleKey = 'dialog.done'
70
                 okTitleKey = 'dialog.done'
73
                 titleString = { titleString }>
71
                 titleString = { titleString }>
74
                 <div className = 'invite-dialog'>
72
                 <div className = 'invite-dialog'>
75
-                    <ShareLinkForm toCopy = { conferenceUrl } />
76
-                    <DialInNumbersForm conferenceUrl = { conferenceUrl } />
73
+                    <ShareLinkForm toCopy = { _inviteURL } />
74
+                    <DialInNumbersForm inviteURL = { _inviteURL } />
77
                     <PasswordContainer
75
                     <PasswordContainer
78
                         conference = { _conference.conference }
76
                         conference = { _conference.conference }
79
                         locked = { _conference.locked }
77
                         locked = { _conference.locked }
93
  * @private
91
  * @private
94
  * @returns {{
92
  * @returns {{
95
  *     _conference: Object,
93
  *     _conference: Object,
94
+ *     _inviteURL: string,
96
  *     _isModerator: boolean
95
  *     _isModerator: boolean
97
  * }}
96
  * }}
98
  */
97
  */
99
 function _mapStateToProps(state) {
98
 function _mapStateToProps(state) {
100
-    const { role }
101
-        = getLocalParticipant(state['features/base/participants']);
102
-
103
     return {
99
     return {
104
         _conference: state['features/base/conference'],
100
         _conference: state['features/base/conference'],
105
-        _isModerator: role === PARTICIPANT_ROLE.MODERATOR
101
+        _inviteURL: getInviteURL(state),
102
+        _isModerator:
103
+            getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
106
     };
104
     };
107
 }
105
 }
108
 
106
 

+ 18
- 22
react/features/invite/reducer.js 查看文件

9
     numbersEnabled: true
9
     numbersEnabled: true
10
 };
10
 };
11
 
11
 
12
-ReducerRegistry.register(
13
-    'features/invite/dial-in',
14
-    (state = DEFAULT_STATE, action) => {
15
-        switch (action.type) {
16
-        case UPDATE_DIAL_IN_NUMBERS_FAILED: {
17
-            return {
18
-                ...state,
19
-                error: action.error
20
-            };
21
-        }
12
+ReducerRegistry.register('features/invite', (state = DEFAULT_STATE, action) => {
13
+    switch (action.type) {
14
+    case UPDATE_DIAL_IN_NUMBERS_FAILED:
15
+        return {
16
+            ...state,
17
+            error: action.error
18
+        };
22
 
19
 
23
-        case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
24
-            const { numbers, numbersEnabled } = action.dialInNumbers;
20
+    case UPDATE_DIAL_IN_NUMBERS_SUCCESS: {
21
+        const { numbers, numbersEnabled } = action.dialInNumbers;
25
 
22
 
26
-            return {
27
-                conferenceId: action.conferenceId.id,
28
-                error: null,
29
-                numbers,
30
-                numbersEnabled
31
-            };
32
-        }
33
-        }
23
+        return {
24
+            conferenceID: action.conferenceID,
25
+            numbers,
26
+            numbersEnabled
27
+        };
28
+    }
29
+    }
34
 
30
 
35
-        return state;
36
-    });
31
+    return state;
32
+});

+ 1
- 11
react/features/overlay/components/FilmstripOnlyOverlayFrame.js 查看文件

115
  * }}
115
  * }}
116
  */
116
  */
117
 function _mapStateToProps(state) {
117
 function _mapStateToProps(state) {
118
-    const participant
119
-        = getLocalParticipant(
120
-            state['features/base/participants']);
121
-    const { avatarId, avatarUrl, email } = participant || {};
122
-
123
     return {
118
     return {
124
-        _avatar: getAvatarURL({
125
-            avatarId,
126
-            avatarUrl,
127
-            email,
128
-            participantId: participant.id
129
-        })
119
+        _avatar: getAvatarURL(getLocalParticipant(state) || {})
130
     };
120
     };
131
 }
121
 }
132
 
122
 

+ 4
- 6
react/features/share-room/actions.js 查看文件

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
+import { getInviteURL } from '../base/connection';
4
+
3
 import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
5
 import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
4
 
6
 
5
 /**
7
 /**
12
 export function beginShareRoom(roomURL: ?string): Function {
14
 export function beginShareRoom(roomURL: ?string): Function {
13
     return (dispatch, getState) => {
15
     return (dispatch, getState) => {
14
         if (!roomURL) {
16
         if (!roomURL) {
15
-            const { locationURL } = getState()['features/base/connection'];
16
-
17
-            if (locationURL) {
18
-                // eslint-disable-next-line no-param-reassign
19
-                roomURL = locationURL.toString();
20
-            }
17
+            // eslint-disable-next-line no-param-reassign
18
+            roomURL = getInviteURL(getState);
21
         }
19
         }
22
         roomURL && dispatch({
20
         roomURL && dispatch({
23
             type: BEGIN_SHARE_ROOM,
21
             type: BEGIN_SHARE_ROOM,

Loading…
取消
儲存