Skip to content

Commit 177072a

Browse files
committed
msglist [nfc]: Use useGlobalSelector to avoid assumeSecretly…
1 parent 2130a04 commit 177072a

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/webview/MessageList.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ import type {
1717
UserOrBot,
1818
EditMessage,
1919
} from '../types';
20-
import { assumeSecretlyGlobalState } from '../reduxTypes';
2120
import { ThemeContext } from '../styles';
22-
import { useSelector, useDispatch } from '../react-redux';
21+
import { useSelector, useDispatch, useGlobalSelector } from '../react-redux';
2322
import {
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

159154
function 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

Comments
 (0)