Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invocation and permissions for notifications #4176

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ function appReady() {

initializeSerialBackend();
});
if (getConfig('showNotifications') && NotificationManager.checkPermission() === 'default') {

const showNotifications = getConfig('showNotifications', false).showNotifications;
if (showNotifications && NotificationManager.checkPermission() === 'default') {
NotificationManager.requestPermission();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/protocols/webstm32.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ class STM32Protocol {
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);

// Show notification
if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('programmingSuccessfulNotification'), icon: "/images/pwa/favicon.ico"});
}

Expand All @@ -817,7 +817,7 @@ class STM32Protocol {
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);

// Show notification
if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('programmingFailedNotification'), icon: "/images/pwa/favicon.ico"});
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/protocols/webusbdfu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ class WEBUSBDFU_protocol extends EventTarget {
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);

// Show notification
if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('programmingSuccessfulNotification'), icon: "/images/pwa/favicon.ico"});
}

Expand All @@ -1079,7 +1079,7 @@ class WEBUSBDFU_protocol extends EventTarget {
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);

// Show notification
if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('programmingFailedNotification'), icon: "/images/pwa/favicon.ico"});
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/tabs/onboard_logging.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ onboard_logging.initialize = function (callback) {

$(".dataflash-saving").addClass("done");

if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('flashDownloadDoneNotification'), icon: "/images/pwa/favicon.ico"});
}
}
Expand Down Expand Up @@ -504,7 +504,7 @@ onboard_logging.initialize = function (callback) {
if (CONFIGURATOR.connectionValid && !eraseCancelled) {
if (FC.DATAFLASH.ready) {
$(".dataflash-confirm-erase")[0].close();
if (getConfig('showNotifications')) {
if (getConfig('showNotifications').showNotifications) {
NotificationManager.showNotification("Betaflight Configurator", {body: i18n.getMessage('flashEraseDoneNotification'), icon: "/images/pwa/favicon.ico"});
}
} else {
Expand Down