Page MenuHomePhabricator

D10663.diff
No OneTemporary

D10663.diff

diff --git a/lib/shared/notifications-session-creator-context.js b/lib/shared/notifications-session-creator-context.js
new file mode 100644
--- /dev/null
+++ b/lib/shared/notifications-session-creator-context.js
@@ -0,0 +1,20 @@
+// @flow
+
+import * as React from 'react';
+
+import type { OLMIdentityKeys } from '../types/crypto-types.js';
+import type { OlmSessionInitializationInfo } from '../types/request-types.js';
+
+export type NotificationsSessionCreatorContextType = {
+ +notificationsSessionCreator: (
+ cookie: ?string,
+ notificationsIdentityKeys: OLMIdentityKeys,
+ notificationsInitializationInfo: OlmSessionInitializationInfo,
+ keyserverID: string,
+ ) => Promise<string>,
+};
+
+const NotificationsSessionCreatorContext: React.Context<?NotificationsSessionCreatorContextType> =
+ React.createContext(null);
+
+export { NotificationsSessionCreatorContext };
diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js
--- a/lib/types/crypto-types.js
+++ b/lib/types/crypto-types.js
@@ -2,7 +2,6 @@
import t, { type TInterface } from 'tcomb';
-import type { OlmSessionInitializationInfo } from '../types/request-types.js';
import { tShape } from '../utils/validation-utils.js';
export type OLMIdentityKeys = {
@@ -37,15 +36,6 @@
+getInitializedCryptoStore: () => Promise<CryptoStore>,
};
-export type NotificationsSessionCreatorContextType = {
- +notificationsSessionCreator: (
- cookie: ?string,
- notificationsIdentityKeys: OLMIdentityKeys,
- notificationsInitializationInfo: OlmSessionInitializationInfo,
- keyserverID: string,
- ) => Promise<string>,
-};
-
export type NotificationsOlmDataType = {
+mainSession: string,
+picklingKey: string,
diff --git a/native/account/account-hooks.js b/native/account/account-hooks.js
new file mode 100644
--- /dev/null
+++ b/native/account/account-hooks.js
@@ -0,0 +1,41 @@
+// @flow
+
+import * as React from 'react';
+
+import { NotificationsSessionCreatorContext } from 'lib/shared/notifications-session-creator-context.js';
+import type { OLMIdentityKeys } from 'lib/types/crypto-types.js';
+import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
+
+import { nativeNotificationsSessionCreator } from '../utils/crypto-utils.js';
+
+type Props = {
+ +children: React.Node,
+};
+
+function notificationsSessionCreator(
+ cookie: ?string,
+ notificationsIdentityKeys: OLMIdentityKeys,
+ notificationsInitializationInfo: OlmSessionInitializationInfo,
+ keyserverID: string,
+) {
+ return nativeNotificationsSessionCreator(
+ notificationsIdentityKeys,
+ notificationsInitializationInfo,
+ keyserverID,
+ );
+}
+
+const contextValue = {
+ notificationsSessionCreator,
+};
+
+function NotificationsSessionCreatorProvider(props: Props): React.Node {
+ const { children } = props;
+ return (
+ <NotificationsSessionCreatorContext.Provider value={contextValue}>
+ {children}
+ </NotificationsSessionCreatorContext.Provider>
+ );
+}
+
+export { NotificationsSessionCreatorProvider };
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -33,6 +33,7 @@
import { TunnelbrokerProvider } from 'lib/tunnelbroker/tunnelbroker-context.js';
import { actionLogger } from 'lib/utils/action-logger.js';
+import { NotificationsSessionCreatorProvider } from './account/account-hooks.js';
import { RegistrationContextProvider } from './account/registration/registration-context-provider.react.js';
import NativeEditThreadAvatarProvider from './avatars/native-edit-thread-avatar-provider.react.js';
import BackupHandler from './backup/backup-handler.js';
@@ -300,60 +301,64 @@
<CallKeyserverEndpointProvider>
<StaffContextProvider>
<IdentityServiceContextProvider>
- <TunnelbrokerProvider
- initMessage={tunnelbrokerInitMessage}
- peerToPeerMessageHandler={peerToPeerMessageHandler}
- >
- <FeatureFlagsProvider>
- <NavContext.Provider value={navContext}>
- <RootContext.Provider value={rootContext}>
- <InputStateContainer>
- <MessageEditingContextProvider>
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
- <ActionSheetProvider>
- <ENSCacheProvider provider={provider}>
- <MediaCacheProvider
- persistence={filesystemMediaCache}
- >
- <EditUserAvatarProvider>
- <NativeEditThreadAvatarProvider>
- <MarkdownContextProvider>
- <MessageSearchProvider>
- <BottomSheetProvider>
- <RegistrationContextProvider>
- <SQLiteDataHandler />
- <ConnectedStatusBar />
- <ReduxPersistGate
- persistor={getPersistor()}
- >
- {gated}
- </ReduxPersistGate>
- <PersistedStateGate>
- <KeyserverConnectionsHandler
- socketComponent={Socket}
- detectUnsupervisedBackgroundRef={
- detectUnsupervisedBackgroundRef
- }
- />
- <VersionSupportedChecker />
- </PersistedStateGate>
- {navigation}
- </RegistrationContextProvider>
- </BottomSheetProvider>
- </MessageSearchProvider>
- </MarkdownContextProvider>
- </NativeEditThreadAvatarProvider>
- </EditUserAvatarProvider>
- </MediaCacheProvider>
- </ENSCacheProvider>
- </ActionSheetProvider>
- </SafeAreaProvider>
- </MessageEditingContextProvider>
- </InputStateContainer>
- </RootContext.Provider>
- </NavContext.Provider>
- </FeatureFlagsProvider>
- </TunnelbrokerProvider>
+ <NotificationsSessionCreatorProvider>
+ <TunnelbrokerProvider
+ initMessage={tunnelbrokerInitMessage}
+ peerToPeerMessageHandler={peerToPeerMessageHandler}
+ >
+ <FeatureFlagsProvider>
+ <NavContext.Provider value={navContext}>
+ <RootContext.Provider value={rootContext}>
+ <InputStateContainer>
+ <MessageEditingContextProvider>
+ <SafeAreaProvider
+ initialMetrics={initialWindowMetrics}
+ >
+ <ActionSheetProvider>
+ <ENSCacheProvider provider={provider}>
+ <MediaCacheProvider
+ persistence={filesystemMediaCache}
+ >
+ <EditUserAvatarProvider>
+ <NativeEditThreadAvatarProvider>
+ <MarkdownContextProvider>
+ <MessageSearchProvider>
+ <BottomSheetProvider>
+ <RegistrationContextProvider>
+ <SQLiteDataHandler />
+ <ConnectedStatusBar />
+ <ReduxPersistGate
+ persistor={getPersistor()}
+ >
+ {gated}
+ </ReduxPersistGate>
+ <PersistedStateGate>
+ <KeyserverConnectionsHandler
+ socketComponent={Socket}
+ detectUnsupervisedBackgroundRef={
+ detectUnsupervisedBackgroundRef
+ }
+ />
+ <VersionSupportedChecker />
+ </PersistedStateGate>
+ {navigation}
+ </RegistrationContextProvider>
+ </BottomSheetProvider>
+ </MessageSearchProvider>
+ </MarkdownContextProvider>
+ </NativeEditThreadAvatarProvider>
+ </EditUserAvatarProvider>
+ </MediaCacheProvider>
+ </ENSCacheProvider>
+ </ActionSheetProvider>
+ </SafeAreaProvider>
+ </MessageEditingContextProvider>
+ </InputStateContainer>
+ </RootContext.Provider>
+ </NavContext.Provider>
+ </FeatureFlagsProvider>
+ </TunnelbrokerProvider>
+ </NotificationsSessionCreatorProvider>
</IdentityServiceContextProvider>
</StaffContextProvider>
</CallKeyserverEndpointProvider>
diff --git a/web/account/account-hooks.js b/web/account/account-hooks.js
--- a/web/account/account-hooks.js
+++ b/web/account/account-hooks.js
@@ -11,13 +11,13 @@
getOneTimeKeyValuesFromBlob,
getPrekeyValueFromBlob,
} from 'lib/shared/crypto-utils.js';
+import { NotificationsSessionCreatorContext } from 'lib/shared/notifications-session-creator-context.js';
import type {
SignedIdentityKeysBlob,
CryptoStore,
IdentityKeysBlob,
CryptoStoreContextType,
OLMIdentityKeys,
- NotificationsSessionCreatorContextType,
NotificationsOlmDataType,
} from 'lib/types/crypto-types.js';
import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
@@ -40,9 +40,6 @@
const CryptoStoreContext: React.Context<?CryptoStoreContextType> =
React.createContext(null);
-const WebNotificationsSessionCreatorContext: React.Context<?NotificationsSessionCreatorContextType> =
- React.createContext(null);
-
type Props = {
+children: React.Node,
};
@@ -177,7 +174,7 @@
}, [getOrCreateCryptoStore]);
}
-function WebNotificationsSessionCreatorProvider(props: Props): React.Node {
+function NotificationsSessionCreatorProvider(props: Props): React.Node {
const getOrCreateCryptoStore = useGetOrCreateCryptoStore();
const currentCryptoStore = useSelector(state => state.cryptoStore);
@@ -310,9 +307,9 @@
);
return (
- <WebNotificationsSessionCreatorContext.Provider value={contextValue}>
+ <NotificationsSessionCreatorContext.Provider value={contextValue}>
{props.children}
- </WebNotificationsSessionCreatorContext.Provider>
+ </NotificationsSessionCreatorContext.Provider>
);
}
@@ -322,7 +319,7 @@
notificationsInitializationInfo: OlmSessionInitializationInfo,
keyserverID: string,
) => Promise<string> {
- const context = React.useContext(WebNotificationsSessionCreatorContext);
+ const context = React.useContext(NotificationsSessionCreatorContext);
invariant(context, 'WebNotificationsSessionCreator not found.');
return context.notificationsSessionCreator;
@@ -331,7 +328,7 @@
export {
useGetSignedIdentityKeysBlob,
useGetOrCreateCryptoStore,
- WebNotificationsSessionCreatorProvider,
+ NotificationsSessionCreatorProvider,
useWebNotificationsSessionCreator,
GetOrCreateCryptoStoreProvider,
};
diff --git a/web/root.js b/web/root.js
--- a/web/root.js
+++ b/web/root.js
@@ -16,7 +16,7 @@
import {
GetOrCreateCryptoStoreProvider,
- WebNotificationsSessionCreatorProvider,
+ NotificationsSessionCreatorProvider,
} from './account/account-hooks.js';
import App from './app.react.js';
import { SQLiteDataHandler } from './database/sqlite-data-handler.js';
@@ -47,14 +47,14 @@
<InitialReduxStateGate persistor={persistor}>
<GetOrCreateCryptoStoreProvider>
<IdentityServiceContextProvider>
- <WebNotificationsSessionCreatorProvider>
+ <NotificationsSessionCreatorProvider>
<Router history={history.getHistoryObject()}>
<Route path="*" component={App} />
</Router>
<KeyserverConnectionsHandler socketComponent={Socket} />
<SQLiteDataHandler />
<IntegrityHandler />
- </WebNotificationsSessionCreatorProvider>
+ </NotificationsSessionCreatorProvider>
</IdentityServiceContextProvider>
</GetOrCreateCryptoStoreProvider>
</InitialReduxStateGate>

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 1:17 PM (21 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2601089
Default Alt Text
D10663.diff (13 KB)

Event Timeline