update dependencies
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
import { produce } from "immer";
|
||||
import { create } from "zustand";
|
||||
|
||||
import { create as createStore } from "zustand";
|
||||
import { Protobuf, Types } from "@meshtastic/js";
|
||||
import { create } from "@bufbuild/protobuf";
|
||||
|
||||
export type Page = "messages" | "map" | "config" | "channels" | "nodes";
|
||||
|
||||
@@ -111,7 +110,7 @@ export interface DeviceState {
|
||||
getDevice: (id: number) => Device | undefined;
|
||||
}
|
||||
|
||||
export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
export const useDeviceStore = createStore<DeviceState>((set, get) => ({
|
||||
devices: new Map(),
|
||||
remoteDevices: new Map(),
|
||||
|
||||
@@ -122,11 +121,11 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
id,
|
||||
status: Types.DeviceStatusEnum.DeviceDisconnected,
|
||||
channels: new Map(),
|
||||
config: new Protobuf.LocalOnly.LocalConfig(),
|
||||
moduleConfig: new Protobuf.LocalOnly.LocalModuleConfig(),
|
||||
config: create(Protobuf.LocalOnly.LocalConfigSchema),
|
||||
moduleConfig: create(Protobuf.LocalOnly.LocalModuleConfigSchema),
|
||||
workingConfig: [],
|
||||
workingModuleConfig: [],
|
||||
hardware: new Protobuf.Mesh.MyNodeInfo(),
|
||||
hardware: create(Protobuf.Mesh.MyNodeInfoSchema),
|
||||
nodes: new Map(),
|
||||
metadata: new Map(),
|
||||
messages: {
|
||||
@@ -138,7 +137,6 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
activePage: "messages",
|
||||
activeNode: 0,
|
||||
waypoints: [],
|
||||
// currentMetrics: new Protobuf.DeviceMetrics(),
|
||||
dialog: {
|
||||
import: false,
|
||||
QR: false,
|
||||
@@ -301,11 +299,11 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
const workingModuleConfigIndex =
|
||||
device?.workingModuleConfig.findIndex(
|
||||
const workingModuleConfigIndex = device?.workingModuleConfig
|
||||
.findIndex(
|
||||
(wmc) =>
|
||||
wmc.payloadVariant.case ===
|
||||
moduleConfig.payloadVariant.case,
|
||||
moduleConfig.payloadVariant.case,
|
||||
);
|
||||
if (workingModuleConfigIndex !== -1) {
|
||||
device.workingModuleConfig[workingModuleConfigIndex] =
|
||||
@@ -447,8 +445,8 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
const currentNode =
|
||||
device.nodes.get(user.from) ?? new Protobuf.Mesh.NodeInfo();
|
||||
const currentNode = device.nodes.get(user.from) ??
|
||||
create(Protobuf.Mesh.NodeInfoSchema);
|
||||
currentNode.user = user.data;
|
||||
device.nodes.set(user.from, currentNode);
|
||||
}),
|
||||
@@ -461,9 +459,8 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
if (!device) {
|
||||
return;
|
||||
}
|
||||
const currentNode =
|
||||
device.nodes.get(position.from) ??
|
||||
new Protobuf.Mesh.NodeInfo();
|
||||
const currentNode = device.nodes.get(position.from) ??
|
||||
create(Protobuf.Mesh.NodeInfoSchema);
|
||||
currentNode.position = position.data;
|
||||
device.nodes.set(position.from, currentNode);
|
||||
}),
|
||||
@@ -487,12 +484,11 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
return;
|
||||
}
|
||||
const messageGroup = device.messages[message.type];
|
||||
const messageIndex =
|
||||
message.type === "direct"
|
||||
? message.from === device.hardware.myNodeNum
|
||||
? message.to
|
||||
: message.from
|
||||
: message.channel;
|
||||
const messageIndex = message.type === "direct"
|
||||
? message.from === device.hardware.myNodeNum
|
||||
? message.to
|
||||
: message.from
|
||||
: message.channel;
|
||||
const messages = messageGroup.get(messageIndex);
|
||||
|
||||
if (messages) {
|
||||
@@ -565,12 +561,9 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
}
|
||||
const messageGroup = device.messages[type];
|
||||
|
||||
const messageIndex =
|
||||
type === "direct"
|
||||
? from === device.hardware.myNodeNum
|
||||
? to
|
||||
: from
|
||||
: channelIndex;
|
||||
const messageIndex = type === "direct"
|
||||
? from === device.hardware.myNodeNum ? to : from
|
||||
: channelIndex;
|
||||
const messages = messageGroup.get(messageIndex);
|
||||
|
||||
if (!messages) {
|
||||
@@ -618,7 +611,7 @@ export const useDeviceStore = create<DeviceState>((set, get) => ({
|
||||
} else {
|
||||
device.nodes.set(
|
||||
data.from,
|
||||
new Protobuf.Mesh.NodeInfo({
|
||||
create(Protobuf.Mesh.NodeInfoSchema, {
|
||||
num: data.from,
|
||||
lastHeard: data.time,
|
||||
snr: data.snr,
|
||||
|
||||
Reference in New Issue
Block a user