This commit is contained in:
Sacha Weatherstone
2021-08-07 22:06:26 +10:00
parent fa5d816d1b
commit 25e3caab0d
8 changed files with 139 additions and 21 deletions
+13 -7
View File
@@ -34,20 +34,25 @@ const App = (): JSX.Element => {
const myNodeInfo = useAppSelector((state) => state.meshtastic.myNodeInfo);
const darkMode = useAppSelector((state) => state.app.darkMode);
const hostOverrideEnabled = useAppSelector(
(state) => state.meshtastic.hostOverrideEnabled,
);
const hostOverride = useAppSelector((state) => state.meshtastic.hostOverride);
React.useEffect(() => {
SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE;
connection.connect({
address:
import.meta.env.NODE_ENV === 'production'
? window.location.hostname
: import.meta.env.SNOWPACK_PUBLIC_DEVICE_IP,
address: hostOverrideEnabled
? hostOverride
: import.meta.env.NODE_ENV === 'production'
? window.location.hostname
: import.meta.env.SNOWPACK_PUBLIC_DEVICE_IP,
receiveBatchRequests: false,
tls: false,
fetchInterval: 2000,
});
}, []);
}, [hostOverrideEnabled, hostOverride]);
React.useEffect(() => {
connection.onDeviceStatus.subscribe((status) => {
@@ -56,6 +61,9 @@ const App = (): JSX.Element => {
if (status === Types.DeviceStatusEnum.DEVICE_CONFIGURED) {
dispatch(setReady(true));
}
if (status === Types.DeviceStatusEnum.DEVICE_DISCONNECTED) {
dispatch(setReady(false));
}
});
connection.onMyNodeInfo.subscribe((nodeInfo) => {
@@ -88,8 +96,6 @@ const App = (): JSX.Element => {
);
connection.onTextPacket.subscribe((message) => {
console.log(message.packet.from, '===', myNodeInfo.myNodeNum);
dispatch(
addMessage({
message: message,