Repository: gitify-app/gitify
Pull request #807 (2024-02-21 11:54:19)

feat: add security_advisory_credit reason
Closes: #782


Patch:
diff --git a/main.js b/main.js
index 56ffc84c..a6d61e19 100644
--- a/main.js
+++ b/main.js
@@ -4,7 +4,7 @@ const { autoUpdater } = require('electron-updater');
 const { onFirstRunMaybe } = require('./first-run');
 const path = require('path');
 
-require('@electron/remote/main').initialize()
+require('@electron/remote/main').initialize();
 
 app.setAppUserModelId('com.electron.gitify');
 
@@ -12,7 +12,7 @@ const iconIdle = path.join(
   __dirname,
   'assets',
   'images',
-  'tray-idleTemplate.png'
+  'tray-idleTemplate.png',
 );
 const iconActive = path.join(__dirname, 'assets', 'images', 'tray-active.png');
 
@@ -30,16 +30,6 @@ const browserWindowOpts = {
   },
 };
 
-const delayedHideAppIcon = () => {
-  if (app.dock && app.dock.hide) {
-    // Setting a timeout because the showDockIcon is not currently working
-    // See more at https://github.com/maxogden/menubar/issues/306
-    setTimeout(() => {
-      app.dock.hide();
-    }, 1500);
-  }
-};
-
 app.on('ready', async () => {
   await onFirstRunMaybe();
 });
@@ -49,11 +39,10 @@ const menubarApp = menubar({
   index: `file://${__dirname}/index.html`,
   browserWindow: browserWindowOpts,
   preloadWindow: true,
+  showDockIcon: false,
 });
 
 menubarApp.on('ready', () => {
-  delayedHideAppIcon();
-
   menubarApp.tray.setIgnoreDoubleClickEvents(true);
 
   autoUpdater.checkForUpdatesAndNotify();
@@ -100,7 +89,7 @@ menubarApp.on('ready', () => {
     const trayBounds = menubarApp.tray.getBounds();
     menubarApp.window.setSize(
       browserWindowOpts.width,
-      browserWindowOpts.height
+      browserWindowOpts.height,
     );
     menubarApp.positioner.move('trayCenter', trayBounds);
     menubarApp.window.resizable = false;
diff --git a/src/typesGithub.ts b/src/typesGithub.ts
index fe80ff92..bbe02f13 100644
--- a/src/typesGithub.ts
+++ b/src/typesGithub.ts
@@ -8,6 +8,7 @@ export type Reason =
   | 'member_feature_requested'
   | 'mention'
   | 'review_requested'
+  | 'security_advisory_credit'
   | 'security_alert'
   | 'state_change'
   | 'subscribed'
diff --git a/src/utils/github-api.ts b/src/utils/github-api.ts
index f5b45395..10811d5b 100644
--- a/src/utils/github-api.ts
+++ b/src/utils/github-api.ts
@@ -28,6 +28,7 @@ const DESCRIPTIONS = {
     MEMBER_FEATURE_REQUESTED: 'Organization members have requested to enable a feature such as Draft Pull Requests or CoPilot.',
     MENTION: 'You were specifically @mentioned in the content.',
     REVIEW_REQUESTED: "You, or a team you're a member of, were requested to review a pull request.",
+    SECURITY_ADVISORY_CREDIT: "You were credited for contributing to a security advisory.",
     SECURITY_ALERT: 'GitHub discovered a security vulnerability in your repository.',
     STATE_CHANGE: 'You changed the thread state (for example, closing an issue or merging a pull request).',
     SUBSCRIBED: "You're watching the repository.",
@@ -58,6 +59,8 @@ export function formatReason(reason: Reason): {
       return { type: 'Mention', description: DESCRIPTIONS['MENTION'] };
     case 'review_requested':
       return { type: 'Review Requested', description: DESCRIPTIONS['REVIEW_REQUESTED'] };
+    case 'security_advisory_credit':
+      return { type: 'Security Advisory Credit', description: DESCRIPTIONS['SECURITY_ADVISORY_CREDIT'] };
     case 'security_alert':
       return { type: 'Security Alert', description: DESCRIPTIONS['SECURITY_ALERT'] };
     case 'state_change':


Test patch:
diff --git a/src/utils/__snapshots__/github-api.test.ts.snap b/src/utils/__snapshots__/github-api.test.ts.snap
index 09d81888..758f59fc 100644
--- a/src/utils/__snapshots__/github-api.test.ts.snap
+++ b/src/utils/__snapshots__/github-api.test.ts.snap
@@ -80,34 +80,41 @@ exports[`./utils/github-api.ts should format the notification reason 9`] = `
 `;
 
 exports[`./utils/github-api.ts should format the notification reason 10`] = `
+{
+  "description": "You were credited for contributing to a security advisory.",
+  "type": "Security Advisory Credit",
+}
+`;
+
+exports[`./utils/github-api.ts should format the notification reason 11`] = `
 {
   "description": "GitHub discovered a security vulnerability in your repository.",
   "type": "Security Alert",
 }
 `;
 
-exports[`./utils/github-api.ts should format the notification reason 11`] = `
+exports[`./utils/github-api.ts should format the notification reason 12`] = `
 {
   "description": "You changed the thread state (for example, closing an issue or merging a pull request).",
   "type": "State Change",
 }
 `;
 
-exports[`./utils/github-api.ts should format the notification reason 12`] = `
+exports[`./utils/github-api.ts should format the notification reason 13`] = `
 {
   "description": "You're watching the repository.",
   "type": "Subscribed",
 }
 `;
 
-exports[`./utils/github-api.ts should format the notification reason 13`] = `
+exports[`./utils/github-api.ts should format the notification reason 14`] = `
 {
   "description": "You were on a team that was mentioned.",
   "type": "Team Mention",
 }
 `;
 
-exports[`./utils/github-api.ts should format the notification reason 14`] = `
+exports[`./utils/github-api.ts should format the notification reason 15`] = `
 {
   "description": "The reason for this notification is not supported by the app.",
   "type": "Unknown",
diff --git a/src/utils/github-api.test.ts b/src/utils/github-api.test.ts
index 8a055d37..5ce25403 100644
--- a/src/utils/github-api.test.ts
+++ b/src/utils/github-api.test.ts
@@ -16,6 +16,7 @@ describe('./utils/github-api.ts', () => {
     expect(formatReason('member_feature_requested')).toMatchSnapshot();
     expect(formatReason('mention')).toMatchSnapshot();
     expect(formatReason('review_requested')).toMatchSnapshot();
+    expect(formatReason('security_advisory_credit')).toMatchSnapshot();
     expect(formatReason('security_alert')).toMatchSnapshot();
     expect(formatReason('state_change')).toMatchSnapshot();
     expect(formatReason('subscribed')).toMatchSnapshot();