|
@@ -1,9 +1,11 @@
|
1
|
1
|
// @flow
|
2
|
2
|
import _ from 'lodash';
|
3
|
3
|
|
|
4
|
+import { PREJOIN_INITIALIZED } from '../../prejoin/actionTypes';
|
4
|
5
|
import { APP_WILL_MOUNT } from '../app';
|
5
|
6
|
import { setAudioOnly } from '../audio-only';
|
6
|
7
|
import { SET_LOCATION_URL } from '../connection/actionTypes'; // minimize imports to avoid circular imports
|
|
8
|
+import { getJwtName } from '../jwt/functions';
|
7
|
9
|
import { getLocalParticipant, participantUpdated } from '../participants';
|
8
|
10
|
import { MiddlewareRegistry } from '../redux';
|
9
|
11
|
import { parseURLParams } from '../util';
|
|
@@ -27,6 +29,10 @@ MiddlewareRegistry.register(store => next => action => {
|
27
|
29
|
case APP_WILL_MOUNT:
|
28
|
30
|
_initializeCallIntegration(store);
|
29
|
31
|
break;
|
|
32
|
+ case PREJOIN_INITIALIZED: {
|
|
33
|
+ _maybeUpdateDisplayName(store);
|
|
34
|
+ break;
|
|
35
|
+ }
|
30
|
36
|
case SETTINGS_UPDATED:
|
31
|
37
|
_maybeHandleCallIntegrationChange(action);
|
32
|
38
|
_maybeSetAudioOnly(store, action);
|
|
@@ -115,6 +121,26 @@ function _maybeSetAudioOnly(
|
115
|
121
|
}
|
116
|
122
|
}
|
117
|
123
|
|
|
124
|
+/**
|
|
125
|
+ * Updates the display name to the one in JWT if there is one.
|
|
126
|
+ *
|
|
127
|
+ * @param {Store} store - The redux store.
|
|
128
|
+ * @private
|
|
129
|
+ * @returns {void}
|
|
130
|
+ */
|
|
131
|
+function _maybeUpdateDisplayName({ dispatch, getState }) {
|
|
132
|
+ const state = getState();
|
|
133
|
+ const hasJwt = Boolean(state['features/base/jwt'].jwt);
|
|
134
|
+
|
|
135
|
+ if (hasJwt) {
|
|
136
|
+ const displayName = getJwtName(state);
|
|
137
|
+
|
|
138
|
+ dispatch(updateSettings({
|
|
139
|
+ displayName
|
|
140
|
+ }));
|
|
141
|
+ }
|
|
142
|
+}
|
|
143
|
+
|
118
|
144
|
/**
|
119
|
145
|
* Updates the local participant according to settings changes.
|
120
|
146
|
*
|