File tree Expand file tree Collapse file tree 1 file changed +18
-11
lines changed
src/modules/OpenChannel/context Expand file tree Collapse file tree 1 file changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -21,22 +21,29 @@ export const shouldFetchMore = (messageLength: number, maxMessages?: number): bo
21
21
} ;
22
22
23
23
/* eslint-disable default-param-last */
24
- export const scrollIntoLast = ( initialTry = 0 , scrollRef : React . RefObject < HTMLElement > ) : void => {
24
+ export const scrollIntoLast = (
25
+ initialTry = 0 ,
26
+ scrollRef : React . RefObject < HTMLElement > ,
27
+ ) : void => {
25
28
const MAX_TRIES = 10 ;
26
- const currentTry = initialTry ;
27
- if ( currentTry > MAX_TRIES ) {
29
+
30
+ if ( initialTry > MAX_TRIES ) {
28
31
return ;
29
32
}
30
- try {
31
- const scrollDOM = scrollRef ?. current || document . querySelector ( '.sendbird-openchannel-conversation-scroll__container__item-container' ) ;
32
- // eslint-disable-next-line no-multi-assign
33
- if ( scrollDOM ) {
33
+
34
+ const scrollDOM = scrollRef ?. current
35
+ || document . querySelector ( '.sendbird-openchannel-conversation-scroll__container__item-container' ) ;
36
+
37
+ if ( scrollDOM ) {
38
+ const applyScroll = ( ) => {
39
+ scrollDOM . style . overflow = 'auto' ;
34
40
scrollDOM . scrollTop = scrollDOM . scrollHeight ;
35
- }
36
- } catch ( error ) {
41
+ } ;
42
+ setTimeout ( applyScroll ) ;
43
+ } else {
37
44
setTimeout ( ( ) => {
38
- scrollIntoLast ( currentTry + 1 , scrollRef ) ;
39
- } , 500 * currentTry ) ;
45
+ scrollIntoLast ( initialTry + 1 , scrollRef ) ;
46
+ } , 500 * initialTry ) ;
40
47
}
41
48
} ;
42
49
You can’t perform that action at this time.
0 commit comments