Page MenuHomePhabricator

D5213.id16990.diff
No OneTemporary

D5213.id16990.diff

diff --git a/native/data/core-data-provider.react.js b/native/data/core-data-provider.react.js
--- a/native/data/core-data-provider.react.js
+++ b/native/data/core-data-provider.react.js
@@ -3,6 +3,7 @@
import * as React from 'react';
import { useSelector } from 'react-redux';
+import { commCoreModule } from '../native-modules';
import { type CoreData, defaultCoreData, CoreDataContext } from './core-data';
type Props = {
@@ -15,7 +16,7 @@
React.useEffect(() => {
(async () => {
- const fetchedDrafts = await global.CommCoreModule.getAllDrafts();
+ const fetchedDrafts = await commCoreModule.getAllDrafts();
setDraftCache(prevDrafts => {
const mergedDrafts = {};
for (const draftObj of fetchedDrafts) {
@@ -37,7 +38,7 @@
const oldDrafts = draftCache;
setDraftCache({});
try {
- return await global.CommCoreModule.removeAllDrafts();
+ return await commCoreModule.removeAllDrafts();
} catch (e) {
setDraftCache(oldDrafts);
throw e;
@@ -88,7 +89,7 @@
const prevDraftText = draftCache[draft.key];
setDrafts([draft]);
try {
- return await global.CommCoreModule.updateDraft(draft);
+ return await commCoreModule.updateDraft(draft);
} catch (e) {
setDrafts([{ key: draft.key, text: prevDraftText }]);
throw e;
@@ -108,7 +109,7 @@
{ key: prevKey, text: null },
]);
try {
- return await global.CommCoreModule.moveDraft(prevKey, newKey);
+ return await commCoreModule.moveDraft(prevKey, newKey);
} catch (e) {
setDrafts([
{ key: newKey, text: null },
diff --git a/native/data/core-data.js b/native/data/core-data.js
--- a/native/data/core-data.js
+++ b/native/data/core-data.js
@@ -4,6 +4,8 @@
import { draftKeyFromThreadID } from 'lib/shared/thread-utils';
+import { commCoreModule } from '../native-modules';
+
export type UpdateDraft = (draft: {
+key: string,
+text: string,
@@ -22,8 +24,8 @@
const defaultCoreData = Object.freeze({
drafts: {
data: ({}: { +[key: string]: string }),
- updateDraft: global.CommCoreModule.updateDraft,
- moveDraft: global.CommCoreModule.moveDraft,
+ updateDraft: commCoreModule.updateDraft,
+ moveDraft: commCoreModule.moveDraft,
},
});
diff --git a/native/data/sensitive-data-cleaner.react.js b/native/data/sensitive-data-cleaner.react.js
--- a/native/data/sensitive-data-cleaner.react.js
+++ b/native/data/sensitive-data-cleaner.react.js
@@ -3,6 +3,7 @@
import * as React from 'react';
import ExitApp from 'react-native-exit-app';
+import { commCoreModule } from '../native-modules';
import { useSelector } from '../redux/redux-utils';
function SensitiveDataCleaner(): null {
@@ -12,15 +13,15 @@
React.useEffect(() => {
(async () => {
try {
- const databaseCurrentUserInfoID = await global.CommCoreModule.getCurrentUserID();
+ const databaseCurrentUserInfoID = await commCoreModule.getCurrentUserID();
if (
databaseCurrentUserInfoID &&
databaseCurrentUserInfoID !== currentLoggedInUserID
) {
- await global.CommCoreModule.clearSensitiveData();
+ await commCoreModule.clearSensitiveData();
}
if (currentLoggedInUserID) {
- await global.CommCoreModule.setCurrentUserID(currentLoggedInUserID);
+ await commCoreModule.setCurrentUserID(currentLoggedInUserID);
}
} catch (e) {
if (__DEV__) {
diff --git a/native/data/sqlite-context-provider.js b/native/data/sqlite-context-provider.js
--- a/native/data/sqlite-context-provider.js
+++ b/native/data/sqlite-context-provider.js
@@ -9,6 +9,7 @@
import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils';
import { convertClientDBThreadInfosToRawThreadInfos } from 'lib/utils/thread-ops-utils';
+import { commCoreModule } from '../native-modules';
import { useSelector } from '../redux/redux-utils';
import { SQLiteContext } from './sqlite-context';
@@ -32,7 +33,7 @@
}
(async () => {
try {
- const threads = await global.CommCoreModule.getAllThreads();
+ const threads = await commCoreModule.getAllThreads();
const threadInfosFromDB = convertClientDBThreadInfosToRawThreadInfos(
threads,
);
@@ -40,7 +41,7 @@
type: setThreadStoreActionType,
payload: { threadInfos: threadInfosFromDB },
});
- const messages = await global.CommCoreModule.getAllMessages();
+ const messages = await commCoreModule.getAllMessages();
dispatch({
type: setMessageStoreMessages,
payload: messages,
diff --git a/native/native-modules.js b/native/native-modules.js
new file mode 100644
--- /dev/null
+++ b/native/native-modules.js
@@ -0,0 +1,5 @@
+// @flow
+
+import type { Spec } from './schema/CommCoreModuleSchema';
+
+export const commCoreModule: Spec = global.CommCoreModule;
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -24,6 +24,7 @@
import { translateRawMessageInfoToClientDBMessageInfo } from 'lib/utils/message-ops-utils';
import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils';
+import { commCoreModule } from '../native-modules';
import { defaultNotifPermissionAlertInfo } from '../push/alerts';
import { defaultDeviceCameraInfo } from '../types/camera';
import { defaultGlobalThemeInfo } from '../types/themes';
@@ -206,7 +207,7 @@
[22]: state => {
for (const key in state.drafts) {
const value = state.drafts[key];
- global.CommCoreModule.updateDraft({
+ commCoreModule.updateDraft({
key,
text: value,
});
@@ -340,7 +341,7 @@
payload: { id, threadInfo: threadInfos[id] },
})),
];
- const processingResult: boolean = global.CommCoreModule.processThreadStoreOperationsSync(
+ const processingResult: boolean = commCoreModule.processThreadStoreOperationsSync(
convertThreadStoreOperationsToClientDBOperations(operations),
);
if (!processingResult) {
@@ -359,7 +360,7 @@
payload: translateRawMessageInfoToClientDBMessageInfo(messages[id]),
})),
];
- const processingResult: boolean = global.CommCoreModule.processMessageStoreOperationsSync(
+ const processingResult: boolean = commCoreModule.processMessageStoreOperationsSync(
operations,
);
if (!processingResult) {
@@ -438,7 +439,7 @@
timeout: ((__DEV__ ? 0 : undefined): number | void),
};
-const codeVersion: number = global.CommCoreModule.getCodeVersion();
+const codeVersion: number = commCoreModule.getCodeVersion();
// This local exists to avoid a circular dependency where redux-setup needs to
// import all the navigation and screen stuff, but some of those screens want to
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -35,6 +35,7 @@
import { convertMessageStoreOperationsToClientDBOperations } from 'lib/utils/message-ops-utils';
import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils';
+import { commCoreModule } from '../native-modules';
import { defaultNavInfo } from '../navigation/default-state';
import { getGlobalNavContext } from '../navigation/icky-global';
import { activeMessageListSelector } from '../navigation/nav-selectors';
@@ -318,14 +319,14 @@
const promises = [];
if (convertedThreadStoreOperations.length > 0) {
promises.push(
- global.CommCoreModule.processThreadStoreOperations(
+ commCoreModule.processThreadStoreOperations(
convertedThreadStoreOperations,
),
);
}
if (convertedMessageStoreOperations.length > 0) {
promises.push(
- global.CommCoreModule.processMessageStoreOperations(
+ commCoreModule.processMessageStoreOperations(
convertedMessageStoreOperations,
),
);
diff --git a/native/selectors/socket-selectors.js b/native/selectors/socket-selectors.js
--- a/native/selectors/socket-selectors.js
+++ b/native/selectors/socket-selectors.js
@@ -41,7 +41,7 @@
function oneTimeKeyGenerator(inc: number): string {
// todo replace this hard code with something like
- // global.CommCoreModule.generateOneTimeKeys()
+ // commCoreModule.generateOneTimeKeys()
let str = Date.now().toString() + '_' + inc.toString() + '_';
while (str.length < 43) {
str += Math.random().toString(36).substr(2, 5);

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 1, 7:35 PM (18 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2399244
Default Alt Text
D5213.id16990.diff (8 KB)

Event Timeline