fix: timestamp to date, and building .aar
This commit is contained in:
parent
b2624f4db1
commit
98ef3d59f8
|
@ -67,6 +67,6 @@ android/keystores/debug.keystore
|
|||
lib/
|
||||
|
||||
tmp/
|
||||
android/libs/gowaku-sources.jar
|
||||
android/libs/gowaku.aar
|
||||
gowaku-sources.jar
|
||||
gowaku.aar
|
||||
ios/Gowaku.xcframework
|
|
@ -6,6 +6,12 @@ Waku React Native
|
|||
npm install @waku/react-native
|
||||
```
|
||||
|
||||
Edit `settings.gradle` from your app and add:
|
||||
```
|
||||
include ':gowaku'
|
||||
project(':gowaku').projectDir = new File(rootProject.projectDir, './../node_modules/@waku/react-native/android/gowaku')
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
|
|
|
@ -133,8 +133,8 @@ dependencies {
|
|||
//noinspection GradleDynamicVersion
|
||||
implementation "com.facebook.react:react-native:+"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation files('libs/gowaku.aar')
|
||||
// From node_modules
|
||||
implementation project(":gowaku")
|
||||
// From node_modules
|
||||
}
|
||||
|
||||
if (isNewArchitectureEnabled()) {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
configurations.maybeCreate("default")
|
||||
artifacts.add("default", file('gowaku.aar'))
|
|
@ -0,0 +1 @@
|
|||
include ':gowaku'
|
|
@ -41,8 +41,8 @@ if [ "$DOWNLOAD_ANDROID" = true ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
rm -f ../android/libs/gowaku*
|
||||
tar xvfz ${ANDROID_TAR} -C ../android/libs
|
||||
rm -f ../android/gowaku/gowaku*
|
||||
tar xvfz ${ANDROID_TAR} -C ../android/gowaku
|
||||
fi
|
||||
|
||||
if [ "$DOWNLOAD_IOS" = true ]; then
|
||||
|
|
|
@ -92,7 +92,7 @@ export default function App() {
|
|||
// TO RETRIEVE HISTORIC MESSAGES:
|
||||
console.log('Retrieving messages from store node');
|
||||
const query = new StoreQuery();
|
||||
query.contentFilters.push(new ContentFilter('test-rramos'));
|
||||
query.contentFilters.push(new ContentFilter('ABC'));
|
||||
const queryResult = await storeQuery(
|
||||
query,
|
||||
'16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm'
|
||||
|
|
|
@ -15,3 +15,6 @@ if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true")
|
|||
include(":ReactAndroid:hermes-engine")
|
||||
project(":ReactAndroid:hermes-engine").projectDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../ReactAndroid/hermes-engine");
|
||||
}
|
||||
|
||||
include ':gowaku'
|
||||
project(':gowaku').projectDir = new File(rootProject.projectDir, './../node_modules/@waku/react-native/android/gowaku')
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@waku/react-native",
|
||||
"version": "0.0.12",
|
||||
"version": "0.1.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@waku/react-native",
|
||||
"version": "0.0.12",
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base-64": "^1.0.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@waku/react-native",
|
||||
"version": "0.0.12",
|
||||
"version": "0.1.0",
|
||||
"description": "Waku React Native",
|
||||
"author": "Status Research & Development GMBH",
|
||||
"authors": [
|
||||
|
|
|
@ -19,7 +19,7 @@ const ReactNative = NativeModules.ReactNative
|
|||
}
|
||||
);
|
||||
|
||||
const OneMillion = bigInt(1_000_000);
|
||||
const OneMillion = bigInt(1000000);
|
||||
|
||||
export class WakuMessage {
|
||||
payload: Uint8Array = new Uint8Array();
|
||||
|
@ -51,7 +51,10 @@ export function onMessage(cb: (arg0: any) => void) {
|
|||
let signal = JSON.parse(event.signal);
|
||||
let msg = signal.event.wakuMessage;
|
||||
signal.event.wakuMessage = new WakuMessage();
|
||||
signal.event.wakuMessage.timestamp = msg.timestamp;
|
||||
signal.event.wakuMessage.timestamp =
|
||||
msg.timestamp != 0
|
||||
? new Date(bigInt(msg.timestamp).divide(OneMillion).toJSNumber())
|
||||
: undefined;
|
||||
signal.event.wakuMessage.version = msg.version || 0;
|
||||
signal.event.wakuMessage.contentTopic = msg.contentTopic;
|
||||
signal.event.wakuMessage.payload = new Uint8Array(
|
||||
|
@ -734,9 +737,18 @@ export function storeQuery(
|
|||
if (response.error) {
|
||||
reject(response.error);
|
||||
} else {
|
||||
if(response.result.messages){
|
||||
for(let i = 0; i < response.result.messages.length; i++){
|
||||
response.result.messages[i].payload = new Uint8Array(decode(response.result.messages[i].payload ?? []).split('').map(c => c.charCodeAt(0)));
|
||||
if (response.result.messages) {
|
||||
for (let i = 0; i < response.result.messages.length; i++) {
|
||||
const t = response.result.messages[i].timestamp;
|
||||
response.result.messages[i].timestamp =
|
||||
t != 0
|
||||
? new Date(bigInt(t).divide(OneMillion).toJSNumber())
|
||||
: undefined;
|
||||
response.result.messages[i].payload = new Uint8Array(
|
||||
decode(response.result.messages[i].payload ?? [])
|
||||
.split('')
|
||||
.map((c) => c.charCodeAt(0))
|
||||
);
|
||||
}
|
||||
}
|
||||
resolve(response.result);
|
||||
|
|
Loading…
Reference in New Issue