COnnection modal fix & notification basics
This commit is contained in:
@@ -23,6 +23,8 @@ import {
|
||||
Types,
|
||||
} from '@meshtastic/meshtasticjs';
|
||||
|
||||
import { showNotification } from './utils/notifications.js';
|
||||
|
||||
type connectionType = IBLEConnection | IHTTPConnection | ISerialConnection;
|
||||
|
||||
export let connection: connectionType = new IHTTPConnection();
|
||||
@@ -151,6 +153,7 @@ const registerListeners = (): void => {
|
||||
|
||||
connection.onTextPacket.subscribe((message) => {
|
||||
const myNodeNum = store.getState().meshtastic.radio.hardware.myNodeNum;
|
||||
showNotification('New message', message.data);
|
||||
|
||||
store.dispatch(
|
||||
addMessage({
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export const requestNotificationPermission = async (): Promise<void> => {
|
||||
if (window.Notification && Notification.permission !== 'denied') {
|
||||
await Notification.requestPermission();
|
||||
}
|
||||
};
|
||||
|
||||
export const showNotification = (title: string, body: string): void => {
|
||||
new Notification(title, {
|
||||
body,
|
||||
icon: 'android-512.png',
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user