wip
This commit is contained in:
@@ -9,6 +9,7 @@ export interface RasterSource {
|
||||
tileSize: number;
|
||||
}
|
||||
|
||||
|
||||
interface ErrorState {
|
||||
field: string;
|
||||
message: string;
|
||||
@@ -19,7 +20,12 @@ interface ErrorState {
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface AppState {
|
||||
export interface App {
|
||||
unreadCounts: Map<number, number>;
|
||||
setUnread: (id: number, count: number) => void;
|
||||
}
|
||||
|
||||
export interface AppState {
|
||||
selectedDevice: number;
|
||||
devices: {
|
||||
id: number;
|
||||
@@ -34,6 +40,7 @@ interface AppState {
|
||||
activeChat: number;
|
||||
chatType: "broadcast" | "direct";
|
||||
errors: ErrorState[];
|
||||
unreadCounts: Map<number, number>;
|
||||
|
||||
setRasterSources: (sources: RasterSource[]) => void;
|
||||
addRasterSource: (source: RasterSource) => void;
|
||||
@@ -56,6 +63,9 @@ interface AppState {
|
||||
removeError: (field: string) => void;
|
||||
clearErrors: () => void;
|
||||
setNewErrors: (newErrors: ErrorState[]) => void;
|
||||
|
||||
// unread counts
|
||||
setUnread: (id: number, count: number) => void;
|
||||
}
|
||||
|
||||
export const useAppStore = create<AppState>()((set, get) => ({
|
||||
@@ -70,6 +80,7 @@ export const useAppStore = create<AppState>()((set, get) => ({
|
||||
activeChat: Types.ChannelNumber.Primary,
|
||||
chatType: "broadcast",
|
||||
errors: [],
|
||||
unreadCounts: new Map([[0, 100],[2718471552, 1]]),
|
||||
|
||||
setRasterSources: (sources: RasterSource[]) => {
|
||||
set(
|
||||
@@ -178,4 +189,11 @@ export const useAppStore = create<AppState>()((set, get) => ({
|
||||
}),
|
||||
);
|
||||
},
|
||||
setUnread: (id: number, count: number) => {
|
||||
set(
|
||||
produce<AppState>((draft) => {
|
||||
draft.unreadCounts.set(id, count);
|
||||
})
|
||||
);
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface Device {
|
||||
pkiBackup: boolean;
|
||||
nodeDetails: boolean;
|
||||
};
|
||||
unreadCounts: Map<number, number>;
|
||||
|
||||
setStatus: (status: Types.DeviceStatusEnum) => void;
|
||||
setConfig: (config: Protobuf.Config.Config) => void;
|
||||
@@ -98,6 +99,7 @@ export interface Device {
|
||||
setDialogOpen: (dialog: DialogVariant, open: boolean) => void;
|
||||
processPacket: (data: ProcessPacketParams) => void;
|
||||
setMessageDraft: (message: string) => void;
|
||||
setUnread: (id: number, count: number) => void;
|
||||
}
|
||||
|
||||
export interface DeviceState {
|
||||
@@ -149,6 +151,7 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
|
||||
},
|
||||
pendingSettingsChanges: false,
|
||||
messageDraft: "",
|
||||
unreadCounts: new Map([[0, 100],[2718471552, 1]]),
|
||||
|
||||
setStatus: (status: Types.DeviceStatusEnum) => {
|
||||
set(
|
||||
@@ -631,6 +634,17 @@ export const useDeviceStore = createStore<DeviceState>((set, get) => ({
|
||||
}),
|
||||
);
|
||||
},
|
||||
setUnread: (id: number, count: number) => {
|
||||
set(
|
||||
produce<DeviceState>((draft) => {
|
||||
console.log(id, count);
|
||||
const device = draft.devices.get(id);
|
||||
if (device) {
|
||||
device.unreadCounts.set(id, count);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user