From c33f3cddcc97faae82fc4d719626d85db4317486 Mon Sep 17 00:00:00 2001 From: HoonBaek Date: Fri, 7 Jan 2022 08:15:43 +0900 Subject: [PATCH] Check if nickname and profileUrl are null or empty string --- src/lib/dux/sdk/thunks.js | 5 ++++- src/utils/index.ts | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/dux/sdk/thunks.js b/src/lib/dux/sdk/thunks.js index 8fdc2900e..0bb7b1b38 100644 --- a/src/lib/dux/sdk/thunks.js +++ b/src/lib/dux/sdk/thunks.js @@ -7,6 +7,7 @@ import { SDK_ERROR, } from './actionTypes'; import { INIT_USER, UPDATE_USER_INFO, RESET_USER } from '../user/actionTypes'; +import { isTextuallyNull } from '../../../utils'; const APP_VERSION_STRING = '__uikit_app_version__'; const IS_ROLLUP = '__is_rollup__'; @@ -66,7 +67,9 @@ export const handleConnection = ({ userDispatcher({ type: INIT_USER, payload: user }); // use nickname/profileUrl if provided // or set userID as nickname - if ((nickname !== user.nickname || profileUrl !== user.profileUrl) && (nickname !== '' || profileUrl !== '')) { + if ((nickname !== user.nickname || profileUrl !== user.profileUrl) + && !(isTextuallyNull(nickname) && isTextuallyNull(profileUrl)) + ) { newSdk.updateCurrentUserInfo(nickname || user.nickname, profileUrl || user.profileUrl) .then((namedUser) => { userDispatcher({ type: UPDATE_USER_INFO, payload: namedUser }); diff --git a/src/utils/index.ts b/src/utils/index.ts index fc5ac52ca..fbcabbc47 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -96,6 +96,13 @@ const OutgoingMessageStates: OutgoingMessageStates = { export type CoreMessageType = AdminMessage | UserMessage | FileMessage; +export const isTextuallyNull = (text: string): boolean => { + if (text === '' || text === null) { + return true; + } + return false; +}; + export const isImage = (type: string): boolean => SUPPORTED_MIMES.IMAGE.indexOf(type) >= 0; export const isVideo = (type: string): boolean => SUPPORTED_MIMES.VIDEO.indexOf(type) >= 0; export const isGif = (type: string): boolean => type === 'image/gif';