diff --git a/src/hooks/VoiceRecorder/index.tsx b/src/hooks/VoiceRecorder/index.tsx index 5376e4367..4d589dac6 100644 --- a/src/hooks/VoiceRecorder/index.tsx +++ b/src/hooks/VoiceRecorder/index.tsx @@ -37,7 +37,7 @@ export const VoiceRecorderProvider = (props: VoiceRecorderProps): React.ReactEle const { children } = props; const { config } = useSendbirdStateContext(); const { logger, isVoiceMessageEnabled } = config; - const [mediaRecorder, setMediaRecorder] = useState(null); + const [mediaRecorder, setMediaRecorder] = useState(null); const [isRecordable, setIsRecordable] = useState(false); const [permissionWarning, setPermissionWarning] = useState(false); const { stringSet } = useLocalization(); diff --git a/src/modules/Channel/components/Message/index.tsx b/src/modules/Channel/components/Message/index.tsx index bca51b160..06f91f7f9 100644 --- a/src/modules/Channel/components/Message/index.tsx +++ b/src/modules/Channel/components/Message/index.tsx @@ -42,7 +42,7 @@ const Message = (props: MessageProps): React.ReactElement => { channel={currentGroupChannel} emojiContainer={emojiContainer} editInputDisabled={ - !initialized || isDisabledBecauseFrozen(currentGroupChannel) || isDisabledBecauseMuted(currentGroupChannel) || !config.isOnline + !initialized || isDisabledBecauseFrozen(currentGroupChannel ?? undefined) || isDisabledBecauseMuted(currentGroupChannel ?? undefined) || !config.isOnline } shouldRenderSuggestedReplies={ config?.groupChannel?.enableSuggestedReplies @@ -55,8 +55,8 @@ const Message = (props: MessageProps): React.ReactElement => { && localMessages?.length === 0 && getSuggestedReplies(message).length > 0 } - isReactionEnabled={isReactionEnabled} - replyType={replyType} + isReactionEnabled={isReactionEnabled ?? false} + replyType={replyType ?? 'NONE'} threadReplySelectType={threadReplySelectType} nicknamesMap={nicknamesMap} renderUserMentionItem={renderUserMentionItem} diff --git a/src/modules/Channel/context/hooks/useToggleReactionCallback.ts b/src/modules/Channel/context/hooks/useToggleReactionCallback.ts index f722a4170..ffa984357 100644 --- a/src/modules/Channel/context/hooks/useToggleReactionCallback.ts +++ b/src/modules/Channel/context/hooks/useToggleReactionCallback.ts @@ -17,7 +17,7 @@ export default function useToggleReactionCallback( (message: BaseMessage, key: string, isReacted: boolean) => { if (isReacted) { currentGroupChannel - .deleteReaction(message, key) + ?.deleteReaction(message, key) .then((res) => { logger.info('Delete reaction success', res); }) @@ -26,7 +26,7 @@ export default function useToggleReactionCallback( }); } else { currentGroupChannel - .addReaction(message, key) + ?.addReaction(message, key) .then((res) => { logger.info('Add reaction success', res); }) diff --git a/src/modules/Channel/context/hooks/useUpdateMessageCallback.ts b/src/modules/Channel/context/hooks/useUpdateMessageCallback.ts index c5bc48592..e4619deff 100644 --- a/src/modules/Channel/context/hooks/useUpdateMessageCallback.ts +++ b/src/modules/Channel/context/hooks/useUpdateMessageCallback.ts @@ -42,7 +42,7 @@ function useUpdateMessageCallback( const params: UserMessageUpdateParams = { message, }; - if (isMentionEnabled && mentionedUsers&& mentionedUsers.length > 0) { + if (isMentionEnabled && mentionedUsers && mentionedUsers.length > 0) { params.mentionedUsers = mentionedUsers; } if (isMentionEnabled && mentionTemplate) { diff --git a/src/modules/ChannelList/components/ChannelListUI/index.tsx b/src/modules/ChannelList/components/ChannelListUI/index.tsx index 3ea7ed7af..c0ae97d1f 100644 --- a/src/modules/ChannelList/components/ChannelListUI/index.tsx +++ b/src/modules/ChannelList/components/ChannelListUI/index.tsx @@ -100,9 +100,9 @@ const ChannelListUI: React.FC = (props: ChannelListUIProps) renderPlaceHolderError={renderPlaceHolderError} renderPlaceHolderLoading={renderPlaceHolderLoading} renderPlaceHolderEmptyList={renderPlaceHolderEmptyList} - onChangeTheme={onThemeChange} - allowProfileEdit={allowProfileEdit} - onUserProfileUpdated={onProfileEditSuccess} + onChangeTheme={onThemeChange ?? (() => {})} + allowProfileEdit={allowProfileEdit ?? false} + onUserProfileUpdated={onProfileEditSuccess ?? (() => {})} channels={allChannels} onLoadMore={fetchChannelList} initialized={initialized} diff --git a/src/modules/ChannelList/context/ChannelListProvider.tsx b/src/modules/ChannelList/context/ChannelListProvider.tsx index 48c1c99cd..9a8016baa 100644 --- a/src/modules/ChannelList/context/ChannelListProvider.tsx +++ b/src/modules/ChannelList/context/ChannelListProvider.tsx @@ -108,7 +108,7 @@ export interface ChannelListProviderInterface extends ChannelListProviderProps { fetchChannelList: () => void; } -const ChannelListContext = React.createContext({ +const ChannelListContext = React.createContext({ disableUserProfile: true, allowProfileEdit: true, onBeforeCreateChannel: null, diff --git a/src/modules/ChannelSettings/components/ChannelSettingsUI/index.tsx b/src/modules/ChannelSettings/components/ChannelSettingsUI/index.tsx index f8aa7ac26..c5ac82496 100644 --- a/src/modules/ChannelSettings/components/ChannelSettingsUI/index.tsx +++ b/src/modules/ChannelSettings/components/ChannelSettingsUI/index.tsx @@ -33,7 +33,7 @@ const ChannelSettingsUI: React.FC = ({ const { stringSet } = useContext(LocalizationContext); const state = useSendbirdStateContext(); - const { channel, invalidChannel, onCloseClick, loading } = useChannelSettingsContext(); + const { channel, invalidChannel, onCloseClick, loading } = useChannelSettingsContext() ?? {}; const [showLeaveChannelModal, setShowLeaveChannelModal] = useState(false); diff --git a/src/modules/ChannelSettings/components/EditDetailsModal/index.tsx b/src/modules/ChannelSettings/components/EditDetailsModal/index.tsx index fadc3ab21..84bc412da 100644 --- a/src/modules/ChannelSettings/components/EditDetailsModal/index.tsx +++ b/src/modules/ChannelSettings/components/EditDetailsModal/index.tsx @@ -29,7 +29,7 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { onChannelModified, onBeforeUpdateChannel, setChannelUpdateId, - } = useChannelSettingsContext(); + } = useChannelSettingsContext() ?? {}; const title = channel?.name; const state = useSendbirdStateContext(); @@ -37,11 +37,11 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { const theme = state?.config?.theme; const logger = state?.config?.logger; - const inputRef = useRef(null); - const formRef = useRef(null); - const hiddenInputRef = useRef(null); - const [currentImg, setCurrentImg] = useState(null); - const [newFile, setNewFile] = useState(null); + const inputRef = useRef(null); + const formRef = useRef(null); + const hiddenInputRef = useRef(null); + const [currentImg, setCurrentImg] = useState(null); + const [newFile, setNewFile] = useState(null); const { stringSet } = useContext(LocalizationContext); return ( @@ -51,14 +51,14 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { submitText={stringSet.BUTTON__SAVE} onCancel={onCancel} onSubmit={() => { - if (title !== '' && !inputRef.current.value) { - if (formRef.current.reportValidity) { // might not work in explorer + if (title !== '' && !inputRef.current?.value) { + if (formRef.current?.reportValidity) { // might not work in explorer formRef.current.reportValidity(); } return; } - const currentTitle = inputRef.current.value; + const currentTitle = inputRef.current?.value; const currentImg = newFile; logger.info('ChannelSettings: Channel information being updated', { currentTitle, @@ -66,7 +66,7 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { }); if (onBeforeUpdateChannel) { logger.info('ChannelSettings: onBeforeUpdateChannel'); - const params = onBeforeUpdateChannel(currentTitle, currentImg, channel?.data); + const params = onBeforeUpdateChannel(currentTitle ?? '', currentImg, channel?.data); channel?.updateChannel(params).then((groupChannel) => { onChannelModified?.(groupChannel); setChannelUpdateId(uuidv4()); @@ -81,7 +81,7 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { }).then((groupChannel) => { logger.info('ChannelSettings: Channel information updated', groupChannel); onChannelModified?.(groupChannel); - setChannelUpdateId(uuidv4()); + setChannelUpdateId?.(uuidv4()); onSubmit(); }); } @@ -123,14 +123,18 @@ const EditDetails: React.FC = (props: EditDetailsProps) => { accept="image/gif, image/jpeg, image/png" style={{ display: 'none' }} onChange={(e) => { - setCurrentImg(URL.createObjectURL(e.target.files[0])); - setNewFile(e.target.files[0]); - hiddenInputRef.current.value = ''; + if (e.target.files) { + setCurrentImg(URL.createObjectURL(e.target.files[0])); + setNewFile(e.target.files[0]); + } + if (hiddenInputRef.current) { + hiddenInputRef.current.value = ''; + } }} /> hiddenInputRef.current.click()} + onClick={() => hiddenInputRef.current?.click()} disableUnderline >