Skip to content

Commit d7075e3

Browse files
authored
fixed a bug where scrollToMessage (#1377)
[fix]: Fixed a bug where scrollToMessage Fixes [CLNP-7835](https://sendbird.atlassian.net/browse/CLNP-7835) ### Changelogs - Fixed a bug where scrollToMessage ### Checklist Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If unsure, ask the members. This is a reminder of what we look for before merging your code. - [x] **All tests pass locally with my changes** - [ ] **I have added tests that prove my fix is effective or that my feature works** - [ ] **Public components / utils / props are appropriately exported** - [ ] I have added necessary documentation (if appropriate) ## External Contributions This project is not yet set up to accept pull requests from external contributors. If you have a pull request that you believe should be accepted, please contact the Developer Relations team <developer-advocates@sendbird.com> with details and we'll evaluate if we can set up a [CLA](https://en.wikipedia.org/wiki/Contributor_License_Agreement) to allow for the contribution. [CLNP-7835]: https://sendbird.atlassian.net/browse/CLNP-7835?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 6eb003d commit d7075e3

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/modules/App/DesktopLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const DesktopLayout: React.FC<DesktopLayoutProps> = (props: DesktopLayout
8585
onSearchClick: () => {
8686
setShowSettings(false);
8787
setShowThread(false);
88-
setShowSearch(!showSearch);
88+
setShowSearch((prev: boolean) => { return !prev; });
8989
},
9090
onReplyInThread: onClickThreadReply,
9191
onQuoteMessageClick: ({ message }) => {

src/modules/App/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface DesktopLayoutProps extends AppLayoutProps, SubLayoutCommonProps
4444
showSettings: boolean;
4545
setShowSettings: React.Dispatch<boolean>;
4646
showSearch: boolean;
47-
setShowSearch: React.Dispatch<boolean>;
47+
setShowSearch: React.Dispatch<React.SetStateAction<boolean>>;
4848
// thread
4949
showThread: boolean;
5050
setShowThread: React.Dispatch<boolean>;

src/modules/GroupChannel/context/hooks/useGroupChannel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,21 @@ export const useGroupChannel = () => {
128128

129129
if (message) {
130130
const topOffset = getMessageTopOffset(message.createdAt);
131-
if (topOffset) state.scrollPubSub.publish('scroll', { top: topOffset, animated: scrollAnimated });
131+
if (topOffset !== null) state.scrollPubSub.publish('scroll', { top: topOffset, animated: scrollAnimated });
132132
if (messageFocusAnimated ?? true) setAnimatedMessageId(messageId);
133133
} else if (state.initialized) {
134134
await state.resetWithStartingPoint(createdAt);
135135
setTimeout(() => {
136136
const topOffset = getMessageTopOffset(createdAt);
137-
if (topOffset) {
137+
if (topOffset !== null) {
138138
state.scrollPubSub.publish('scroll', {
139139
top: topOffset,
140140
lazy: false,
141141
animated: scrollAnimated,
142142
});
143143
}
144144
if (messageFocusAnimated ?? true) setAnimatedMessageId(messageId);
145-
});
145+
}, 500);
146146
}
147147
clickHandler.activate();
148148
}, [

src/modules/MessageSearch/context/hooks/useMessageSearch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const useMessageSearch = () => {
6060
store.setState(state => ({ ...state, allMessages: [] }));
6161
}, [store]);
6262

63-
const setSelectedMessageId = (messageId: number) => useCallback(() => {
63+
const setSelectedMessageId = useCallback((messageId: number) => {
6464
store.setState(state => ({ ...state, selectedMessageId: messageId }));
6565
}, [store]);
6666

0 commit comments

Comments
 (0)