WIP
This commit is contained in:
+4
-4
@@ -34,9 +34,10 @@ const App = (): JSX.Element => {
|
||||
|
||||
React.useEffect(() => {
|
||||
const client = new Client();
|
||||
const tmpConnection = client.createHTTPConnection();
|
||||
const httpConnection = client.createHTTPConnection();
|
||||
SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE;
|
||||
|
||||
tmpConnection.connect({
|
||||
httpConnection.connect({
|
||||
address:
|
||||
import.meta.env.NODE_ENV === 'production'
|
||||
? window.location.hostname
|
||||
@@ -45,8 +46,7 @@ const App = (): JSX.Element => {
|
||||
tls: false,
|
||||
fetchInterval: 2000,
|
||||
});
|
||||
setConnection(tmpConnection);
|
||||
SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE;
|
||||
setConnection(httpConnection);
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
+6
-1
@@ -3,7 +3,10 @@ import './index.css';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import App from './App';
|
||||
import store from './store';
|
||||
|
||||
const rootElement = document.getElementById('root');
|
||||
if (!rootElement) throw new Error('Failed to find the root element');
|
||||
@@ -11,7 +14,9 @@ const root = ReactDOM.createRoot(rootElement);
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { Protobuf } from '@meshtastic/meshtasticjs';
|
||||
import { configureStore, createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
const nodesSlice = createSlice({
|
||||
name: 'nodes',
|
||||
initialState: {
|
||||
members: [],
|
||||
},
|
||||
reducers: {
|
||||
addMember: (state: Protobuf.NodeInfo[], node: Protobuf.NodeInfo) => {
|
||||
// Redux Toolkit allows us to write "mutating" logic in reducers. It
|
||||
// doesn't actually mutate the state because it uses the Immer library,
|
||||
// which detects changes to a "draft state" and produces a brand new
|
||||
// immutable state based off those changes
|
||||
state.push(node);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default configureStore({
|
||||
reducer: {
|
||||
nodes: nodesSlice.reducer,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user