Update Hashicon & messages provisioning

This commit is contained in:
Sacha Weatherstone
2022-02-08 16:45:13 +11:00
parent 83cb8badd1
commit 0245a95fa9
8 changed files with 127 additions and 137 deletions
+12
View File
@@ -8,6 +8,11 @@ export interface MessageWithAck {
received: Date;
}
export interface Chat {
id: number; //Channel or user id (for dm's)
messages: MessageWithAck[];
}
export interface ChannelData {
channel: Protobuf.Channel;
lastChatInterraction: Date;
@@ -54,6 +59,7 @@ interface MeshtasticState {
radio: Radio;
hostOverrideEnabled: boolean;
hostOverride: string;
chats: Chat[];
}
const initialState: MeshtasticState = {
@@ -71,6 +77,7 @@ const initialState: MeshtasticState = {
hostOverrideEnabled:
localStorage.getItem('hostOverrideEnabled') === 'true' ?? false,
hostOverride: localStorage.getItem('hostOverride') ?? '',
chats: [],
};
export const meshtasticSlice = createSlice({
@@ -262,6 +269,11 @@ export const meshtasticSlice = createSlice({
// connection.disconnect();
}
},
addChat: (state, action: PayloadAction<Chat>) => {
if (state.chats.findIndex((chat) => chat.id === action.payload.id)) {
state.chats.push(action.payload);
}
},
resetState: (state) => {
state.deviceStatus = Types.DeviceStatusEnum.DEVICE_DISCONNECTED;
state.nodes = [];