Changeset View
Changeset View
Standalone View
Standalone View
native/socket.react.js
Show All 24 Lines | |||||
import { useSelector } from './redux/redux-utils.js'; | import { useSelector } from './redux/redux-utils.js'; | ||||
import { noDataAfterPolicyAcknowledgmentSelector } from './selectors/account-selectors.js'; | import { noDataAfterPolicyAcknowledgmentSelector } from './selectors/account-selectors.js'; | ||||
import { | import { | ||||
openSocketSelector, | openSocketSelector, | ||||
sessionIdentificationSelector, | sessionIdentificationSelector, | ||||
nativeGetClientResponsesSelector, | nativeGetClientResponsesSelector, | ||||
nativeSessionStateFuncSelector, | nativeSessionStateFuncSelector, | ||||
} from './selectors/socket-selectors.js'; | } from './selectors/socket-selectors.js'; | ||||
import { useInitialNotificationsEncryptedMessage } from './utils/crypto-utils.js'; | |||||
const NativeSocket: React.ComponentType<BaseSocketProps> = | const NativeSocket: React.ComponentType<BaseSocketProps> = | ||||
React.memo<BaseSocketProps>(function NativeSocket(props: BaseSocketProps) { | React.memo<BaseSocketProps>(function NativeSocket(props: BaseSocketProps) { | ||||
const inputState = React.useContext(InputStateContext); | const inputState = React.useContext(InputStateContext); | ||||
const navContext = React.useContext(NavContext); | const navContext = React.useContext(NavContext); | ||||
const cookie = useSelector(state => state.cookie); | const cookie = useSelector(state => state.cookie); | ||||
const urlPrefix = useSelector(state => state.urlPrefix); | const urlPrefix = useSelector(state => state.urlPrefix); | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | const activeThread = React.useMemo(() => { | ||||
return null; | return null; | ||||
} | } | ||||
return activeMessageListSelector(navContext); | return activeMessageListSelector(navContext); | ||||
}, [active, navContext]); | }, [active, navContext]); | ||||
const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
const dispatchActionPromise = useDispatchActionPromise(); | const dispatchActionPromise = useDispatchActionPromise(); | ||||
const callLogOut = useServerCall(logOut); | const callLogOut = useServerCall(logOut); | ||||
const getInitialNotificationsEncryptedMessage = | |||||
useInitialNotificationsEncryptedMessage(); | |||||
const socketCrashLoopRecovery = React.useCallback(async () => { | const socketCrashLoopRecovery = React.useCallback(async () => { | ||||
if (!accountHasPassword(currentUserInfo)) { | if (!accountHasPassword(currentUserInfo)) { | ||||
dispatchActionPromise( | dispatchActionPromise( | ||||
logOutActionTypes, | logOutActionTypes, | ||||
callLogOut(preRequestUserState), | callLogOut(preRequestUserState), | ||||
); | ); | ||||
Alert.alert( | Alert.alert( | ||||
'Log in needed', | 'Log in needed', | ||||
'After acknowledging the policies, we need you to log in to your account again', | 'After acknowledging the policies, we need you to log in to your account again', | ||||
[{ text: 'OK' }], | [{ text: 'OK' }], | ||||
); | ); | ||||
return; | return; | ||||
} | } | ||||
await fetchNewCookieFromNativeCredentials( | await fetchNewCookieFromNativeCredentials( | ||||
dispatch, | dispatch, | ||||
cookie, | cookie, | ||||
urlPrefix, | urlPrefix, | ||||
logInActionSources.refetchUserDataAfterAcknowledgment, | logInActionSources.refetchUserDataAfterAcknowledgment, | ||||
getInitialNotificationsEncryptedMessage, | |||||
); | ); | ||||
}, [ | }, [ | ||||
callLogOut, | callLogOut, | ||||
cookie, | cookie, | ||||
currentUserInfo, | currentUserInfo, | ||||
dispatch, | dispatch, | ||||
dispatchActionPromise, | dispatchActionPromise, | ||||
preRequestUserState, | preRequestUserState, | ||||
urlPrefix, | urlPrefix, | ||||
getInitialNotificationsEncryptedMessage, | |||||
]); | ]); | ||||
return ( | return ( | ||||
<Socket | <Socket | ||||
{...props} | {...props} | ||||
active={active} | active={active} | ||||
openSocket={openSocket} | openSocket={openSocket} | ||||
getClientResponses={getClientResponses} | getClientResponses={getClientResponses} | ||||
activeThread={activeThread} | activeThread={activeThread} | ||||
sessionStateFunc={sessionStateFunc} | sessionStateFunc={sessionStateFunc} | ||||
sessionIdentification={sessionIdentification} | sessionIdentification={sessionIdentification} | ||||
cookie={cookie} | cookie={cookie} | ||||
urlPrefix={urlPrefix} | urlPrefix={urlPrefix} | ||||
connection={connection} | connection={connection} | ||||
currentCalendarQuery={currentCalendarQuery} | currentCalendarQuery={currentCalendarQuery} | ||||
canSendReports={canSendReports} | canSendReports={canSendReports} | ||||
frozen={frozen} | frozen={frozen} | ||||
preRequestUserState={preRequestUserState} | preRequestUserState={preRequestUserState} | ||||
dispatch={dispatch} | dispatch={dispatch} | ||||
dispatchActionPromise={dispatchActionPromise} | dispatchActionPromise={dispatchActionPromise} | ||||
logOut={callLogOut} | logOut={callLogOut} | ||||
noDataAfterPolicyAcknowledgment={noDataAfterPolicyAcknowledgment} | noDataAfterPolicyAcknowledgment={noDataAfterPolicyAcknowledgment} | ||||
socketCrashLoopRecovery={socketCrashLoopRecovery} | socketCrashLoopRecovery={socketCrashLoopRecovery} | ||||
getInitialNotificationsEncryptedMessage={ | |||||
getInitialNotificationsEncryptedMessage | |||||
} | |||||
/> | /> | ||||
); | ); | ||||
}); | }); | ||||
export default NativeSocket; | export default NativeSocket; |