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 CannedMessage = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -49,7 +49,14 @@ export const CannedMessage = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "cannedMessage",
cannedMessage: data
}
})
),
{
loading: "Saving...",
success: "Saved Canned Message Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const ExternalNotification = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -39,7 +39,14 @@ export const ExternalNotification = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "externalNotification",
externalNotification: data
}
})
),
{
loading: "Saving...",
success: "Saved External Notification Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const MQTT = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -46,7 +46,14 @@ export const MQTT = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "mqtt",
mqtt: data
}
})
),
{
loading: "Saving...",
success: "Saved MQTT Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const RangeTest = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -40,7 +40,14 @@ export const RangeTest = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "rangeTest",
rangeTest: data
}
})
),
{
loading: "Saving...",
success: "Saved Range Test Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const Serial = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -40,7 +40,14 @@ export const Serial = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "serial",
serial: data
}
})
),
{
loading: "Saving...",
success: "Saved Serial Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const StoreForward = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -40,7 +40,14 @@ export const StoreForward = (): JSX.Element => {
}
}
})
.then(() => reset({ ...data })),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "storeForward",
storeForward: data
}
})
),
{
loading: "Saving...",
success: "Saved Store & Forward Config, Restarting Node",

View File

@@ -12,7 +12,7 @@ import { useDevice } from "@core/providers/useDevice.js";
import { classValidatorResolver } from "@hookform/resolvers/class-validator";
export const Telemetry = (): JSX.Element => {
const { moduleConfig, connection } = useDevice();
const { moduleConfig, connection, setModuleConfig } = useDevice();
const {
register,
handleSubmit,
@@ -40,10 +40,14 @@ export const Telemetry = (): JSX.Element => {
}
}
})
.then(async () => {
reset({ ...data });
await Promise.resolve();
}),
.then(() =>
setModuleConfig({
payloadVariant: {
oneofKind: "telemetry",
telemetry: data
}
})
),
{
loading: "Saving...",
success: "Saved Telemetry Config, Restarting Node",