Kaynağa Gözat

Move ConferenceUrl.inviteURL into React and redux

master
Lyubo Marinov 8 yıl önce
ebeveyn
işleme
ec454d1da0

+ 2
- 2
lang/main.json Dosyayı Görüntüle

@@ -435,11 +435,11 @@
435 435
     "invite": {
436 436
         "addPassword": "Add password",
437 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 439
         "howToDialIn": "To dial in, use one of the following numbers and meeting ID",
440 440
         "hidePassword": "Hide password",
441 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 443
         "locked": "This call is locked. New callers must have the link and enter the password to join.",
444 444
         "showPassword": "Show password",
445 445
         "unlocked": "This call is unlocked. Any new caller with the link may join the call."

+ 3
- 18
modules/URL/ConferenceUrl.js Dosyayı Görüntüle

@@ -24,24 +24,9 @@ export default class ConferenceUrl {
24 24
      * from the sample URL.
25 25
      */
26 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 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 Dosyayı Görüntüle

@@ -121,12 +121,11 @@ function _addConferenceListeners(conference, dispatch) {
121 121
  * @returns {void}
122 122
  */
123 123
 function _setLocalParticipantData(conference, state) {
124
-    const localParticipant
125
-        = getLocalParticipant(state['features/base/participants']);
124
+    const { avatarID } = getLocalParticipant(state);
126 125
 
127 126
     conference.removeCommand(AVATAR_ID_COMMAND);
128 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 Dosyayı Görüntüle

@@ -0,0 +1,26 @@
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 Dosyayı Görüntüle

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

+ 26
- 19
react/features/base/participants/functions.js Dosyayı Görüntüle

@@ -69,13 +69,14 @@ export function getAvatarURL(participant) {
69 69
 /**
70 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 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 81
     return participants.find(p => p.local);
81 82
 }
@@ -83,15 +84,16 @@ export function getLocalParticipant(participantsOrGetState) {
83 84
 /**
84 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 91
  * @param {string} id - The ID of the participant to retrieve.
90 92
  * @private
91 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 98
     return participants.find(p => p.id === id);
97 99
 }
@@ -99,17 +101,22 @@ export function getParticipantById(participantsOrGetState, id) {
99 101
 /**
100 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 108
  * @private
106 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 Dosyayı Görüntüle

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

+ 26
- 27
react/features/invite/actions.js Dosyayı Görüntüle

@@ -15,23 +15,22 @@ declare var APP: Object;
15 15
  * @returns {Function}
16 16
  */
17 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 24
  * @returns {Function}
27 25
  */
28 26
 export function updateDialInNumbers() {
29 27
     return (dispatch, getState) => {
28
+        const state = getState();
30 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 34
             dispatch({
36 35
                 type: UPDATE_DIAL_IN_NUMBERS_FAILED,
37 36
                 error: 'URLs for fetching dial in numbers not properly defined'
@@ -40,30 +39,30 @@ export function updateDialInNumbers() {
40 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 46
         Promise.all([
48 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 Dosyayı Görüntüle

@@ -35,14 +35,15 @@ class DialInNumbersForm extends Component {
35 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 49
          * Invoked to obtain translated strings.
@@ -134,21 +135,21 @@ class DialInNumbersForm extends Component {
134 135
      */
135 136
     render() {
136 137
         const { _dialIn, t } = this.props;
137
-        const { conferenceId, numbers, numbersEnabled } = _dialIn;
138
+        const { conferenceID, numbers, numbersEnabled } = _dialIn;
138 139
         const { selectedNumber } = this.state;
139 140
 
140
-        if (!conferenceId || !numbers || !numbersEnabled || !selectedNumber) {
141
+        if (!conferenceID || !numbers || !numbersEnabled || !selectedNumber) {
141 142
             return null;
142 143
         }
143 144
 
144
-        const items = numbers ? this._formatNumbers(numbers) : [];
145
+        const items = this._formatNumbers(numbers);
145 146
 
146 147
         return (
147 148
             <div className = 'form-control dial-in-numbers'>
148 149
                 <label className = 'form-control__label'>
149 150
                     { t('invite.howToDialIn') }
150 151
                     <span className = 'dial-in-numbers-conference-id'>
151
-                        { conferenceId }
152
+                        { conferenceID }
152 153
                     </span>
153 154
                 </label>
154 155
                 <div className = 'form-control__container'>
@@ -290,18 +291,21 @@ class DialInNumbersForm extends Component {
290 291
      * @returns {string}
291 292
      */
292 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 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 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 310
         return `${welcome}\n${stepOne}\n${stepTwo}`;
307 311
     }
@@ -395,12 +399,9 @@ class DialInNumbersForm extends Component {
395 399
  * }}
396 400
  */
397 401
 function _mapStateToProps(state) {
398
-    const { name }
399
-        = getLocalParticipant(state['features/base/participants']);
400
-
401 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 Dosyayı Görüntüle

@@ -1,6 +1,7 @@
1 1
 import React, { Component } from 'react';
2 2
 import { connect } from 'react-redux';
3 3
 
4
+import { getInviteURL } from '../../base/connection';
4 5
 import { Dialog } from '../../base/dialog';
5 6
 import { translate } from '../../base/i18n';
6 7
 import JitsiMeetJS from '../../base/lib-jitsi-meet';
@@ -24,19 +25,18 @@ class InviteDialog extends Component {
24 25
     static propTypes = {
25 26
         /**
26 27
          * The redux store representation of the JitsiConference.
27
-         *
28 28
          */
29 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 42
          * Invoked to obtain translated strings.
@@ -60,11 +60,9 @@ class InviteDialog extends Component {
60 60
      * @returns {ReactElement}
61 61
      */
62 62
     render() {
63
-        const { _conference, conferenceUrl } = this.props;
63
+        const { _conference, _inviteURL, t } = this.props;
64 64
         const titleString
65
-            = this.props.t(
66
-                'invite.inviteTo',
67
-                { conferenceName: _conference.room });
65
+            = t('invite.inviteTo', { conferenceName: _conference.room });
68 66
 
69 67
         return (
70 68
             <Dialog
@@ -72,8 +70,8 @@ class InviteDialog extends Component {
72 70
                 okTitleKey = 'dialog.done'
73 71
                 titleString = { titleString }>
74 72
                 <div className = 'invite-dialog'>
75
-                    <ShareLinkForm toCopy = { conferenceUrl } />
76
-                    <DialInNumbersForm conferenceUrl = { conferenceUrl } />
73
+                    <ShareLinkForm toCopy = { _inviteURL } />
74
+                    <DialInNumbersForm inviteURL = { _inviteURL } />
77 75
                     <PasswordContainer
78 76
                         conference = { _conference.conference }
79 77
                         locked = { _conference.locked }
@@ -93,16 +91,16 @@ class InviteDialog extends Component {
93 91
  * @private
94 92
  * @returns {{
95 93
  *     _conference: Object,
94
+ *     _inviteURL: string,
96 95
  *     _isModerator: boolean
97 96
  * }}
98 97
  */
99 98
 function _mapStateToProps(state) {
100
-    const { role }
101
-        = getLocalParticipant(state['features/base/participants']);
102
-
103 99
     return {
104 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 Dosyayı Görüntüle

@@ -9,28 +9,24 @@ const DEFAULT_STATE = {
9 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 Dosyayı Görüntüle

@@ -115,18 +115,8 @@ class FilmstripOnlyOverlayFrame extends Component {
115 115
  * }}
116 116
  */
117 117
 function _mapStateToProps(state) {
118
-    const participant
119
-        = getLocalParticipant(
120
-            state['features/base/participants']);
121
-    const { avatarId, avatarUrl, email } = participant || {};
122
-
123 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 Dosyayı Görüntüle

@@ -1,5 +1,7 @@
1 1
 /* @flow */
2 2
 
3
+import { getInviteURL } from '../base/connection';
4
+
3 5
 import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
4 6
 
5 7
 /**
@@ -12,12 +14,8 @@ import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
12 14
 export function beginShareRoom(roomURL: ?string): Function {
13 15
     return (dispatch, getState) => {
14 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 20
         roomURL && dispatch({
23 21
             type: BEGIN_SHARE_ROOM,

Loading…
İptal
Kaydet