Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/dux/sdk/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__';
Expand Down Expand Up @@ -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 });
Expand Down
7 changes: 7 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down