Skip to content

Instantly share code, notes, and snippets.

@marcinwasowicz
Created December 14, 2023 13:15
Show Gist options
  • Save marcinwasowicz/8ae2a80f5f8dfd0708f9496182d861bb to your computer and use it in GitHub Desktop.
Save marcinwasowicz/8ae2a80f5f8dfd0708f9496182d861bb to your computer and use it in GitHub Desktop.
Test CSA Metadata emitter from C++ using appropriate JS file
diff --git a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
index 4ae8b8e3a..2d6d6dff3 100644
--- a/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
+++ b/native/cpp/CommonCpp/NativeModules/DraftStoreOperations.h
@@ -1,5 +1,6 @@
#pragma once
+#include "CommServicesAuthMetadataEmitter.h"
#include "DatabaseManager.h"
#include <jsi/jsi.h>
@@ -20,6 +21,10 @@ public:
text{payload.getProperty(rt, "text").asString(rt).utf8(rt)} {
}
virtual void execute() override {
+ CommServicesAuthMetadataEmitter::sendAuthMetadataToJS(
+ rust::String(std::string("accessToken")),
+ rust::String(std::string("userID")),
+ rust::String(std::string("deviceID")));
DatabaseManager::getQueryExecutor().updateDraft(this->key, this->text);
}
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
index f86933d69..81f8bd0c5 100644
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -44,6 +44,7 @@ import { persistConfig, setPersistor } from './persist.js';
import { onStateDifference } from './redux-debug-utils.js';
import { processDBStoreOperations } from './redux-utils.js';
import type { AppState } from './state-types.js';
+import { getCommServicesAuthMetadataEmitter } from '../event-emitters/csa_auth_metadata_emitter.js';
import { getGlobalNavContext } from '../navigation/icky-global.js';
import { activeMessageListSelector } from '../navigation/nav-selectors.js';
import reactotron from '../reactotron.js';
@@ -344,6 +345,14 @@ function fixUnreadActiveThread(
};
}
+const listener = getCommServicesAuthMetadataEmitter().addListener(
+ 'commServicesAuthMetadata',
+ obj => {
+ console.log(obj);
+ },
+);
+console.log(listener);
+
let appLastBecameInactive = 0;
function appBecameInactive() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment