From e115fc7a7327de7ea47e8a29208405fb0cb1c695 Mon Sep 17 00:00:00 2001 From: OnestarLee Date: Mon, 1 Apr 2024 09:28:35 +0900 Subject: [PATCH 1/6] fix type error --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index d46133bc4..97ba36720 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ // appID for dev mode using storybook -STORYBOOK_APP_ID=xxxx +STORYBOOK_APP_ID='A41EC43B-87A9-40CF-92C5-E178DD0477B1' // for frozen channel testing STORYBOOK_FROZEN_APP_ID= From ce543fa441233945010cf5c58bbdb4be69122501 Mon Sep 17 00:00:00 2001 From: OnestarLee Date: Wed, 3 Apr 2024 15:11:43 +0900 Subject: [PATCH 2/6] fix type error --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 97ba36720..d46133bc4 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ // appID for dev mode using storybook -STORYBOOK_APP_ID='A41EC43B-87A9-40CF-92C5-E178DD0477B1' +STORYBOOK_APP_ID=xxxx // for frozen channel testing STORYBOOK_FROZEN_APP_ID= From 51e9759bddf7345a655e983b934ff7d034a9cb78 Mon Sep 17 00:00:00 2001 From: OnestarLee Date: Fri, 5 Apr 2024 14:26:34 +0900 Subject: [PATCH 3/6] fix type error --- src/hooks/VoiceRecorder/index.tsx | 2 +- .../Channel/components/Message/index.tsx | 6 ++-- .../hooks/useToggleReactionCallback.ts | 4 +-- .../components/ChannelListUI/index.tsx | 6 ++-- .../context/ChannelListProvider.tsx | 2 +- .../components/ChannelSettingsUI/index.tsx | 2 +- .../components/EditDetailsModal/index.tsx | 32 +++++++++-------- .../components/LeaveChannel/index.tsx | 6 ++-- .../ModerationPanel/MutedMemberList.tsx | 3 +- .../ModerationPanel/OperatorList.tsx | 2 +- .../ModerationPanel/OperatorsModal.tsx | 4 +-- .../components/UserListItem/index.tsx | 2 +- .../components/CreateChannelUI/index.tsx | 2 +- .../components/SelectChannelType.tsx | 2 +- .../components/CreateOpenChannelUI/index.tsx | 22 +++++++----- .../components/EditUserProfileUI/index.tsx | 5 +-- .../components/Message/MessageView.tsx | 2 +- .../GroupChannel/components/Message/index.tsx | 6 ++-- .../components/MessageList/index.tsx | 4 +-- .../SuggestedMentionListView.tsx | 8 ++--- .../context/GroupChannelProvider.tsx | 34 +++++++++++-------- .../components/GroupChannelListUI/index.tsx | 4 +-- .../components/MessageSearchUI/index.tsx | 4 +-- .../context/MessageSearchProvider.tsx | 6 ++-- .../context/hooks/useGetSearchedMessages.ts | 6 ++-- .../context/hooks/useSearchStringEffect.ts | 6 ++-- .../components/OpenChannelMessage/index.tsx | 2 +- .../OpenChannel/context/dux/reducers.ts | 1 + .../context/hooks/useSendMessageCallback.ts | 4 +-- src/modules/OpenChannel/context/utils.ts | 2 +- src/modules/OpenChannelApp/Streaming.tsx | 2 +- .../components/CommunityChannelList.tsx | 15 ++++---- .../OpenChannelApp/components/DummyStream.tsx | 2 +- .../components/OpenChannelPreview.tsx | 2 +- .../components/OpenChannelListUI/index.tsx | 4 +-- .../context/hooks/useFetchNextCallback.ts | 4 +-- .../context/hooks/useSetupOpenChannelList.ts | 4 --- .../components/EditDetailsModal.tsx | 14 ++++---- .../components/OperatorUI/BannedUserList.tsx | 4 +-- .../OperatorUI/BannedUsersModal.tsx | 2 +- .../OperatorUI/MutedParticipantList.tsx | 2 +- .../OperatorUI/MutedParticipantsModal.tsx | 2 +- .../components/OperatorUI/OperatorList.tsx | 4 +-- .../components/OperatorUI/OperatorsModal.tsx | 2 +- .../ParticipantUI/ParticipantsModal.tsx | 2 +- .../context/OpenChannelSettingsProvider.tsx | 2 +- .../ParentMessageInfoItem.tsx | 7 ++-- .../Thread/components/RemoveMessageModal.tsx | 2 +- .../Thread/components/ThreadHeader/index.tsx | 2 +- 49 files changed, 142 insertions(+), 127 deletions(-) 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/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..92eb4b060 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..53d89ea27 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,16 @@ 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 >