Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcinwasowicz/da35ee527660a6a020daf88ddae61d24 to your computer and use it in GitHub Desktop.
Save marcinwasowicz/da35ee527660a6a020daf88ddae61d24 to your computer and use it in GitHub Desktop.
CommConstants.NATIVE_MESSAGE_TYPES test
diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js
index 65177918d..e99144987 100644
--- a/native/data/sqlite-data-handler.js
+++ b/native/data/sqlite-data-handler.js
@@ -12,12 +12,13 @@ import {
logInActionSources,
type LogInActionSource,
} from 'lib/types/account-types.js';
+import { messageTypes } from 'lib/types/message-types-enum.js';
import { fetchNewCookieFromNativeCredentials } from 'lib/utils/action-utils.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { convertClientDBThreadInfosToRawThreadInfos } from 'lib/utils/thread-ops-utils.js';
import { filesystemMediaCache } from '../media/media-cache.js';
-import { commCoreModule } from '../native-modules.js';
+import { commCoreModule, commConstants } from '../native-modules.js';
import { setStoreLoadedActionType } from '../redux/action-types.js';
import { useSelector } from '../redux/redux-utils.js';
import { StaffContext } from '../staff/staff-context.js';
@@ -100,6 +101,22 @@ function SQLiteDataHandler(): React.Node {
const handleSensitiveData = React.useCallback(async () => {
try {
+ const messageTypesCpp = new Set(commConstants.NATIVE_MESSAGE_TYPES);
+ const missingMessageTypesCpp = [];
+ for (const messageName in messageTypes) {
+ const messageType = messageTypes[messageName];
+ if (!messageTypesCpp.has(messageType)) {
+ missingMessageTypesCpp.push(messageName);
+ }
+ }
+
+ if (missingMessageTypesCpp.length !== 0) {
+ throw (
+ 'C++ MessageSpec implementation missing for message types: ' +
+ missingMessageTypesCpp.join(', ')
+ );
+ }
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment