Config saving behaviour change

This commit is contained in:
Sacha Weatherstone
2022-12-31 17:14:11 +11:00
parent f7fe27d621
commit ec25ec60ee
18 changed files with 227 additions and 103 deletions

View File

@@ -15,7 +15,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const Bluetooth = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
@@ -44,7 +44,14 @@ export const Bluetooth = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "bluetooth",
bluetooth: data
}
})
),
{
loading: "Saving...",
success: "Saved Bluetooth Config, Restarting Node",

View File

@@ -15,7 +15,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const Device = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
handleSubmit,
@@ -43,7 +43,14 @@ export const Device = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "device",
device: data
}
})
),
{
loading: "Saving...",
success: "Saved Device Config, Restarting Node",

View File

@@ -15,7 +15,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const Display = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
handleSubmit,
@@ -43,7 +43,14 @@ export const Display = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "display",
display: data
}
})
),
{
loading: "Saving...",
success: "Saved Display Config, Restarting Node",

View File

@@ -16,7 +16,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const LoRa = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
@@ -51,7 +51,14 @@ export const LoRa = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "lora",
lora: data
}
})
),
{
loading: "Saving...",
success: "Saved LoRa Config, Restarting Node",

View File

@@ -17,7 +17,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const Network = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
handleSubmit,
@@ -65,7 +65,14 @@ export const Network = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "network",
network: data
}
})
),
{
loading: "Saving...",
success: "Saved Network Config, Restarting Node",

View File

@@ -15,7 +15,7 @@ import { classValidatorResolver } from "@hookform/resolvers/class-validator";
import { Protobuf } from "@meshtastic/meshtasticjs";
export const Position = (): JSX.Element => {
const { config, connection, nodes, hardware } = useDevice();
const { config, connection, nodes, hardware, setConfig } = useDevice();
const myNode = nodes.find((n) => n.data.num === hardware.myNodeNum);
@@ -86,7 +86,14 @@ export const Position = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "position",
position: data
}
})
),
{
loading: "Saving...",
success: "Saved Position Config, Restarting Node",

View File

@@ -13,7 +13,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const Power = (): JSX.Element => {
const { config, connection } = useDevice();
const { config, connection, setConfig } = useDevice();
const {
register,
handleSubmit,
@@ -41,7 +41,14 @@ export const Power = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setConfig({
payloadVariant: {
oneofKind: "power",
power: data
}
})
),
{
loading: "Saving...",
success: "Saved Power Config, Restarting Node",