From a69c483c46cc741aa807640236691da7f52f3f46 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Tue, 18 May 2021 13:47:16 +1000 Subject: [PATCH] Connect to prod fleet by default, test fleet for local development --- CHANGELOG.md | 1 + examples/web-chat/src/App.tsx | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf31a27ebb..2317c72c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Testing: Upgrade nim-waku node to v0.3. - **Breaking**: Modify `WakuStore.queryHistory()` to accept one `Object` instead of multiple individual arguments. - `getStatusFleetNodes` return prod nodes by default, instead of test nodes. +- Examples (web chat): Connect to prod fleet by default, test fleet for local development. ### Fixed - Expose `Enviroment` and `Protocol` enums to pass to `getStatusFleetNodes`. diff --git a/examples/web-chat/src/App.tsx b/examples/web-chat/src/App.tsx index ff697af13f..6169d25483 100644 --- a/examples/web-chat/src/App.tsx +++ b/examples/web-chat/src/App.tsx @@ -3,10 +3,11 @@ import { useEffect, useState } from 'react'; import './App.css'; import { ChatMessage, - WakuMessage, + getStatusFleetNodes, + Environment, StoreCodec, Waku, - getStatusFleetNodes, + WakuMessage, } from 'js-waku'; import handleCommand from './command'; import Room from './Room'; @@ -171,7 +172,7 @@ async function initWaku(setter: (waku: Waku) => void) { setter(waku); - const nodes = await getStatusFleetNodes(); + const nodes = await getNodes(); await Promise.all( nodes.map((addr) => { return waku.dial(addr); @@ -181,3 +182,12 @@ async function initWaku(setter: (waku: Waku) => void) { console.log('Issue starting waku ', e); } } + +function getNodes() { + // Works with react-scripts + if (process?.env?.NODE_ENV === 'development') { + return getStatusFleetNodes(Environment.Test); + } else { + return getStatusFleetNodes(Environment.Prod); + } +}