Ver Fonte

feat: add `silent` option to notifications

tophf há 2 anos atrás
pai
commit
05bdd4a412
1 ficheiros alterados com 4 adições e 1 exclusões
  1. 4 1
      src/background/utils/notifications.js

+ 4 - 1
src/background/utils/notifications.js

@@ -6,7 +6,7 @@ const openers = {};
 
 
 addPublicCommands({
 addPublicCommands({
   /** @return {Promise<string>} */
   /** @return {Promise<string>} */
-  async Notification({ image, text, title, onclick }, src) {
+  async Notification({ image, text, title, silent, onclick }, src) {
     const notificationId = await browser.notifications.create({
     const notificationId = await browser.notifications.create({
       type: 'basic',
       type: 'basic',
       title: [title, IS_FIREFOX && i18n('extName')]::trueJoin(' - '), // Chrome already shows the name
       title: [title, IS_FIREFOX && i18n('extName')]::trueJoin(' - '), // Chrome already shows the name
@@ -15,6 +15,9 @@ addPublicCommands({
       ...!IS_FIREFOX && {
       ...!IS_FIREFOX && {
         requireInteraction: !!onclick,
         requireInteraction: !!onclick,
       },
       },
+      ...ua.chrome >= 70 && {
+        silent,
+      }
     });
     });
     const op = isFunction(onclick) ? onclick : src && [src.tab.id, src.frameId];
     const op = isFunction(onclick) ? onclick : src && [src.tab.id, src.frameId];
     if (op) openers[notificationId] = op;
     if (op) openers[notificationId] = op;