Skip to content

Commit 4a68867

Browse files
Bump @azure/communication-react to 1.25.0 (#181)
1 parent 710caf1 commit 4a68867

7 files changed

Lines changed: 1107 additions & 419 deletions

File tree

Chat/package-lock.json

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

Chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@azure/communication-chat": "^1.5.4",
2222
"@azure/communication-common": "^2.3.1",
2323
"@azure/communication-identity": "^1.3.0",
24-
"@azure/communication-react": "1.24.0",
24+
"@azure/communication-react": "1.25.0",
2525
"@azure/logger": "^1.0.4",
2626
"@fluentui/react": "^8.115.2",
2727
"@fluentui/react-file-type-icons": "8.11.4",

Chat/src/app/ConfigurationScreen.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ import {
4242
import { joinThread } from './utils/joinThread';
4343
import { getEndpointUrl } from './utils/getEndpointUrl';
4444
import { refreshToken } from './utils/refreshToken';
45+
import {
46+
getDisplayNameFromLocalStorage,
47+
localStorageAvailable,
48+
saveDisplayNameToLocalStorage
49+
} from './utils/localStorage';
4550

4651
// These props are set by the caller of ConfigurationScreen in the JSX and not found in context
4752
export interface ConfigurationScreenProps {
@@ -90,6 +95,14 @@ export default (props: ConfigurationScreenProps): JSX.Element => {
9095
const theme = useTheme();
9196
const { joinChatHandler, setToken, setUserId, setDisplayName, setThreadId, setEndpointUrl } = props;
9297

98+
useEffect(() => {
99+
// Get display name from local storage if available
100+
const defaultDisplayName = localStorageAvailable ? getDisplayNameFromLocalStorage() : null;
101+
if (defaultDisplayName) {
102+
setName(defaultDisplayName);
103+
}
104+
}, []);
105+
93106
// Used when new user is being registered.
94107
const setupAndJoinChatThreadWithNewUser = useCallback(() => {
95108
const internalSetupAndJoinChatThread = async (): Promise<void> => {
@@ -179,6 +192,7 @@ export default (props: ConfigurationScreenProps): JSX.Element => {
179192
if (!name) {
180193
setEmptyWarning(true);
181194
} else {
195+
saveDisplayNameToLocalStorage(name);
182196
setEmptyWarning(false);
183197
setDisableJoinChatButton(true);
184198
setConfigurationScreenState(CONFIGURATIONSCREEN_SHOWING_SPINNER_INITIALIZE_CHAT);
@@ -246,6 +260,7 @@ export default (props: ConfigurationScreenProps): JSX.Element => {
246260
</Stack>
247261
</FocusZone>
248262
<DisplayNameField
263+
defaultName={name}
249264
setName={setName}
250265
setEmptyWarning={setEmptyWarning}
251266
validateName={validateName}

Chat/src/app/utils/localStorage.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@
44
export const localStorageAvailable = typeof Storage !== 'undefined';
55

66
export enum LocalStorageKeys {
7+
DisplayName = 'DisplayName',
78
Theme = 'AzureCommunicationUI_Theme'
89
}
910

11+
/**
12+
* Get display name from local storage.
13+
*/
14+
export const getDisplayNameFromLocalStorage = (): string | null =>
15+
window.localStorage.getItem(LocalStorageKeys.DisplayName);
16+
17+
/**
18+
* Save display name into local storage.
19+
*/
20+
export const saveDisplayNameToLocalStorage = (displayName: string): void =>
21+
window.localStorage.setItem(LocalStorageKeys.DisplayName, displayName);
22+
1023
/**
1124
* Get theme from local storage.
1225
*/

0 commit comments

Comments
 (0)