-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CLNP-5046] Migrate ThreadProvider to the new state management pattern #1250
base: feat/state-mgmt-migration-1
Are you sure you want to change the base?
[CLNP-5046] Migrate ThreadProvider to the new state management pattern #1250
Conversation
✅ Deploy Preview for sendbird-uikit-react ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
} = threadContext; | ||
const messageInputRef = useRef(); | ||
|
||
const isMentionEnabled = groupChannel.enableMention; | ||
const isVoiceMessageEnabled = groupChannel.enableVoiceMessage; | ||
const isMultipleFilesMessageEnabled = threadContext.isMultipleFilesMessageEnabled ?? config.isMultipleFilesMessageEnabled; | ||
const isMultipleFilesMessageEnabled = threadContext.state.isMultipleFilesMessageEnabled ?? config.isMultipleFilesMessageEnabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거도 위에 threadContext breakdown 할때 빼서 넣으면 더 좋지 않을까 생각해봤습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
대단한 이유는 아닌데, isMultipleFilesMessageEnabled
의 네이밍이 겹쳐서 이렇게 하긴 했습니다.
type: ThreadContextActionTypes.GET_CHANNEL_FAILURE, | ||
payload: error, | ||
}); | ||
getChannelFailure(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 실패한 에러를 같이 주는건 어떤가요?
type: ThreadContextActionTypes.GET_PARENT_MESSAGE_FAILURE, | ||
payload: error, | ||
}); | ||
getParentMessageFailure(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 에러 같이주면 좋을것 같습니다.
type: ThreadContextActionTypes.GET_CHANNEL_FAILURE, | ||
payload: error, | ||
}); | ||
getChannelFailure(); | ||
}); | ||
} | ||
}, [message, sdkInit]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 message
가 아니라 channelUrl
을 주는게 더 나을것같은데 어떻게 생각하시나요?
url: URL.createObjectURL(file), | ||
// pending thumbnail message seems to be failed | ||
// @ts-ignore | ||
requestState: 'pending', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
제 기억으로는 requestState
는 deprecated 되었고 sendingStatus
가 대체한것같아서 확인 후 맞는걸 사용하도록 바꾸는게 좋지 않을까 생각해봤습니다.
url: URL.createObjectURL(file), | ||
// pending thumbnail message seems to be failed | ||
// @ts-ignore | ||
requestState: 'pending', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기두요!
|
||
const toggleReaction = useToggleReactionCallback({ currentChannel }, { logger }); | ||
|
||
const sendMessage = useCallback((props: SendMessageParams) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 useSendMessageCallback 류의 hook들을 사용하지 않은 이유도 궁금합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이거 관해서 저희가 내부적으로도 이야기를 한 적이 있습니다. 처음에는 가능한 기존에 사용하던 use~~
�훅을 여기서도 사용하려고 했는데 문제가 조금 있습니다.
일단 579 line의 useMemo()
를 기준으로 useMemo() 위에서 �을 사용할 경우 use~~
훅에서 useThread()
를 사용하기 때문에 cycle이 생겨서 훅을 사용할 수 없습니다.
반대로 useMemo()
안에서 훅을 사용할 경우 useMemo 안에서 또다시 훅을 사용하는 케이스가 되므로 리액트 에러가 발생합니다.
이러한 문제들 때문에 기존의 use~~
훅들의 content를 useThread() 내에 풀어서 옮겨놓았습니다.
Overview
This PR migrate ThreadProvider and related files to the new state management pattern.
Changelog
ThreadProvider
is migrated, anduseThread()
hook is introduced.ThreadDispatcher
usages in ThreadProvider; it is replaced with the new state-action pattern ofuseThread()
.PubSub
ofconfig
still remains. It is out of scope of this PR.Remaining tasks
FurtherConcern
ThreadProvider
contained several custom hooks. Those hooks retrieved state and actions throughuseThreadContext()
useThreadContext()
to newuseThread()
faced a problem. Those hooks �conatinuseThread()
,useThread()
contains the hooks. So it makes cycle.useThread()
, but it looks wrong. Any good way to handle this?