start editSettings support

This commit is contained in:
Sacha Weatherstone
2022-12-10 16:13:31 +10:00
parent 6044119bf1
commit fad08fe806
5 changed files with 111 additions and 75 deletions
+13
View File
@@ -56,6 +56,7 @@ export interface Device {
regionUnset: boolean;
currentMetrics: Protobuf.DeviceMetrics;
QRDialogOpen: boolean;
pendingSettingsChanges: boolean;
setReady(ready: boolean): void;
setStatus: (status: Types.DeviceStatusEnum) => void;
@@ -66,6 +67,7 @@ export interface Device {
setActivePage: (page: Page) => void;
setPeerInfoOpen: (open: boolean) => void;
setActivePeer: (peer: number) => void;
setPendingSettingsChanges: (state: boolean) => void;
addChannel: (channel: Channel) => void;
addWaypoint: (waypoint: Protobuf.Waypoint) => void;
addNodeInfo: (nodeInfo: Types.NodeInfoPacket) => void;
@@ -113,6 +115,7 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
regionUnset: false,
currentMetrics: Protobuf.DeviceMetrics.create(),
QRDialogOpen: false,
pendingSettingsChanges: false,
setReady: (ready: boolean) => {
set(
@@ -294,6 +297,16 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
})
);
},
setPendingSettingsChanges: (state) => {
set(
produce<DeviceState>((draft) => {
const device = draft.devices.get(id);
if (device) {
device.pendingSettingsChanges = state;
}
})
);
},
addChannel: (channel: Channel) => {
set(
produce<DeviceState>((draft) => {
+4
View File
@@ -89,4 +89,8 @@ export const subscribeAll = (
ack: messagePacket.packet.from !== myNodeNum
});
});
connection.onPendingSettingsChange.subscribe((state) => {
device.setPendingSettingsChanges(state);
});
};