Skip to content

Commit

Permalink
Fix usage of getConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Sep 20, 2024
1 parent f88b6aa commit 41abe25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
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

0 comments on commit 41abe25

Please sign in to comment.