@@ -17,9 +17,8 @@ import type {
1717 UserOrBot ,
1818 EditMessage ,
1919} from '../types' ;
20- import { assumeSecretlyGlobalState } from '../reduxTypes' ;
2120import { ThemeContext } from '../styles' ;
22- import { useSelector , useDispatch } from '../react-redux' ;
21+ import { useSelector , useDispatch , useGlobalSelector } from '../react-redux' ;
2322import {
2423 getCurrentTypingUsers ,
2524 getDebug ,
@@ -122,15 +121,11 @@ const marksMessagesAsRead = (narrow: Narrow): boolean =>
122121 mentioned : ( ) => false ,
123122 } ) ;
124123
125- function getSelectorProps ( state , props ) {
126- // If this were a function component with Hooks, these would be
127- // useGlobalSelector calls and would coexist perfectly smoothly with
128- // useSelector calls for the per-account data. As long as it's not,
129- // they should probably turn into a `connectGlobal` call.
130- const globalSettings = getGlobalSettings ( assumeSecretlyGlobalState ( state ) ) ;
131- const debug = getDebug ( assumeSecretlyGlobalState ( state ) ) ;
124+ function useSelectorProps ( props : OuterProps ) {
125+ const globalSettings = useGlobalSelector ( getGlobalSettings ) ;
126+ const debug = useGlobalSelector ( getDebug ) ;
132127
133- return {
128+ return useSelector ( state => ( {
134129 backgroundData : getBackgroundData ( state , globalSettings , debug ) ,
135130 fetching : getFetchingForNarrow ( state , props . narrow ) ,
136131 messageListElementsForShownMessages : getMessageListElementsMemoized (
@@ -153,15 +148,15 @@ function getSelectorProps(state, props) {
153148 return false ;
154149 }
155150 } ) ( ) ,
156- } ;
151+ } ) ) ;
157152}
158153
159154function useMessageListProps ( outerProps : OuterProps ) : Props {
160155 const _ = useContext ( TranslationContext ) ;
161156 const showActionSheetWithOptions : ShowActionSheetWithOptions =
162157 useActionSheet ( ) . showActionSheetWithOptions ;
163158 const dispatch = useDispatch ( ) ;
164- const selectorProps = useSelector ( state => getSelectorProps ( state , outerProps ) ) ;
159+ const selectorProps = useSelectorProps ( outerProps ) ;
165160
166161 return {
167162 ...outerProps ,
0 commit comments