Misc fixes

This commit is contained in:
Sacha Weatherstone
2021-12-17 23:09:17 +11:00
parent 8b221e28c5
commit 87dcf35547
14 changed files with 239 additions and 89 deletions
+1 -2
View File
@@ -34,8 +34,7 @@ export const connectionUrl = state.hostOverrideEnabled
? state.hostOverride
: import.meta.env.PROD
? window.location.hostname
: (import.meta.env.VITE_PUBLIC_DEVICE_IP as string) ??
'http://meshtastic.local';
: (import.meta.env.VITE_PUBLIC_DEVICE_IP as string) ?? 'meshtastic.local';
export const ble = new IBLEConnection();
export const serial = new ISerialConnection();
+26
View File
@@ -10,6 +10,17 @@ export enum connType {
SERIAL,
}
interface Notification {
id: string;
icon: React.ReactNode;
title: string;
action?: {
message: string;
action: () => void;
};
read: boolean;
}
interface AppState {
mobileNavOpen: boolean;
connectionModalOpen: boolean;
@@ -21,6 +32,7 @@ interface AppState {
HTTP: Types.HTTPConnectionParameters;
SERIAL: Types.SerialConnectionParameters;
};
notifications: Notification[];
}
const initialState: AppState = {
@@ -39,6 +51,7 @@ const initialState: AppState = {
},
SERIAL: {},
},
notifications: [],
};
export const appSlice = createSlice({
@@ -78,6 +91,17 @@ export const appSlice = createSlice({
state.connectionParams[connType[action.payload.type]] =
action.payload.params;
},
addNotification(state, action: PayloadAction<Notification>) {
state.notifications.push(action.payload);
},
removeNotification(state, action: PayloadAction<string>) {
state.notifications.splice(
state.notifications.findIndex(
(notification) => notification.id === action.payload,
),
1,
);
},
},
});
@@ -90,6 +114,8 @@ export const {
setCurrentPage,
setConnType,
setConnectionParams,
addNotification,
removeNotification,
} = appSlice.actions;
export default appSlice.reducer;