Skip to content

Commit f283278

Browse files
authored
Check if nickname and profileUrl are null or empty string (#76)
1 parent 7232a22 commit f283278

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/lib/dux/sdk/thunks.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SDK_ERROR,
88
} from './actionTypes';
99
import { INIT_USER, UPDATE_USER_INFO, RESET_USER } from '../user/actionTypes';
10+
import { isTextuallyNull } from '../../../utils';
1011

1112
const APP_VERSION_STRING = '__uikit_app_version__';
1213
const IS_ROLLUP = '__is_rollup__';
@@ -66,7 +67,9 @@ export const handleConnection = ({
6667
userDispatcher({ type: INIT_USER, payload: user });
6768
// use nickname/profileUrl if provided
6869
// or set userID as nickname
69-
if ((nickname !== user.nickname || profileUrl !== user.profileUrl) && (nickname !== '' || profileUrl !== '')) {
70+
if ((nickname !== user.nickname || profileUrl !== user.profileUrl)
71+
&& !(isTextuallyNull(nickname) && isTextuallyNull(profileUrl))
72+
) {
7073
newSdk.updateCurrentUserInfo(nickname || user.nickname, profileUrl || user.profileUrl)
7174
.then((namedUser) => {
7275
userDispatcher({ type: UPDATE_USER_INFO, payload: namedUser });

src/utils/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ const OutgoingMessageStates: OutgoingMessageStates = {
9696

9797
export type CoreMessageType = AdminMessage | UserMessage | FileMessage;
9898

99+
export const isTextuallyNull = (text: string): boolean => {
100+
if (text === '' || text === null) {
101+
return true;
102+
}
103+
return false;
104+
};
105+
99106
export const isImage = (type: string): boolean => SUPPORTED_MIMES.IMAGE.indexOf(type) >= 0;
100107
export const isVideo = (type: string): boolean => SUPPORTED_MIMES.VIDEO.indexOf(type) >= 0;
101108
export const isGif = (type: string): boolean => type === 'image/gif';

0 commit comments

Comments
 (0)