diff --git a/native/profile/tunnelbroker-menu.react.js b/native/profile/tunnelbroker-menu.react.js --- a/native/profile/tunnelbroker-menu.react.js +++ b/native/profile/tunnelbroker-menu.react.js @@ -5,6 +5,8 @@ import { Text, View } from 'react-native'; import { ScrollView } from 'react-native-gesture-handler'; +import { setUsersDeviceListsActionType } from 'lib/actions/aux-user-actions.js'; +import { getRelativeUserIDs } from 'lib/selectors/user-selectors.js'; import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; import { useTunnelbroker } from 'lib/tunnelbroker/tunnelbroker-context.js'; import { @@ -19,6 +21,8 @@ createOlmSessionsWithOwnDevices, getContentSigningKey, } from 'lib/utils/crypto-utils.js'; +import { convertSignedDeviceListsToRawDeviceLists } from 'lib/utils/device-list-utils.js'; +import { useDispatch } from 'lib/utils/redux-utils.js'; import type { ProfileNavigationProp } from './profile.react.js'; import Button from '../components/button.react.js'; @@ -89,6 +93,29 @@ } }, [identityContext, sendMessage]); + const dispatch = useDispatch(); + const relativeUserIDs = useSelector(getRelativeUserIDs); + + const onCreateInitialPeerList = React.useCallback(async () => { + if (!identityContext) { + return; + } + try { + const userDeviceLists = + await identityContext.identityClient.getDeviceListsForUsers( + relativeUserIDs, + ); + const usersRawDeviceLists = + convertSignedDeviceListsToRawDeviceLists(userDeviceLists); + dispatch({ + type: setUsersDeviceListsActionType, + payload: usersRawDeviceLists, + }); + } catch (e) { + console.log(`Error creating initial peer list: ${e.message}`); + } + }, [dispatch, identityContext, relativeUserIDs]); + const onSendEncryptedMessage = React.useCallback(async () => { try { if (!currentUserID) { @@ -183,6 +210,15 @@ Create session with own devices +