Repository: gitify-app/gitify
Pull request #707 (2024-01-18 14:51:44)

feat: link to release tag
Closes https://github.com/gitify-app/gitify/issues/670


Patch:
diff --git a/package.json b/package.json
index e1f30d60..657600c6 100644
--- a/package.json
+++ b/package.json
@@ -96,7 +96,7 @@
   "dependencies": {
     "@electron/remote": "2.1.1",
     "@primer/octicons-react": "19.8.0",
-    "axios": "1.6.2",
+    "axios": "1.6.5",
     "date-fns": "2.30.0",
     "electron-updater": "6.1.7",
     "final-form": "4.20.10",
@@ -131,10 +131,10 @@
     "nock": "13.4.0",
     "postcss": "8.4.32",
     "postcss-loader": "7.3.4",
-    "prettier": "3.1.1",
+    "prettier": "3.2.4",
     "react-test-renderer": "18.2.0",
     "style-loader": "3.3.3",
-    "tailwindcss": "3.3.6",
+    "tailwindcss": "3.4.1",
     "ts-jest": "29.1.1",
     "webpack": "5.89.0",
     "webpack-cli": "5.1.4",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5441bf69..178ce1b2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ dependencies:
     specifier: 19.8.0
     version: 19.8.0(react@18.2.0)
   axios:
-    specifier: 1.6.2
-    version: 1.6.2
+    specifier: 1.6.5
+    version: 1.6.5
   date-fns:
     specifier: 2.30.0
     version: 2.30.0
@@ -113,8 +113,8 @@ devDependencies:
     specifier: 7.3.4
     version: 7.3.4(postcss@8.4.32)(typescript@5.3.3)(webpack@5.89.0)
   prettier:
-    specifier: 3.1.1
-    version: 3.1.1
+    specifier: 3.2.4
+    version: 3.2.4
   react-test-renderer:
     specifier: 18.2.0
     version: 18.2.0(react@18.2.0)
@@ -122,8 +122,8 @@ devDependencies:
     specifier: 3.3.3
     version: 3.3.3(webpack@5.89.0)
   tailwindcss:
-    specifier: 3.3.6
-    version: 3.3.6
+    specifier: 3.4.1
+    version: 3.4.1
   ts-jest:
     specifier: 29.1.1
     version: 29.1.1(@babel/core@7.21.8)(jest@29.7.0)(typescript@5.3.3)
@@ -1541,10 +1541,10 @@ packages:
     engines: {node: '>= 0.4'}
     dev: true
 
-  /axios@1.6.2:
-    resolution: {integrity: sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==}
+  /axios@1.6.5:
+    resolution: {integrity: sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==}
     dependencies:
-      follow-redirects: 1.15.2
+      follow-redirects: 1.15.5
       form-data: 4.0.0
       proxy-from-env: 1.1.0
     transitivePeerDependencies:
@@ -2589,8 +2589,8 @@ packages:
     resolution: {integrity: sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==}
     hasBin: true
 
-  /follow-redirects@1.15.2:
-    resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
+  /follow-redirects@1.15.5:
+    resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==}
     engines: {node: '>=4.0'}
     peerDependencies:
       debug: '*'
@@ -4368,8 +4368,8 @@ packages:
     engines: {node: '>= 0.8.0'}
     dev: true
 
-  /prettier@3.1.1:
-    resolution: {integrity: sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==}
+  /prettier@3.2.4:
+    resolution: {integrity: sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==}
     engines: {node: '>=14'}
     hasBin: true
     dev: true
@@ -4972,8 +4972,8 @@ packages:
     resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
     dev: true
 
-  /tailwindcss@3.3.6:
-    resolution: {integrity: sha512-AKjF7qbbLvLaPieoKeTjG1+FyNZT6KaJMJPFeQyLfIp7l82ggH1fbHJSsYIvnbTFQOlkh+gBYpyby5GT1LIdLw==}
+  /tailwindcss@3.4.1:
+    resolution: {integrity: sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==}
     engines: {node: '>=14.0.0'}
     hasBin: true
     dependencies:
diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts
index 31e97fb5..708aac3a 100644
--- a/src/utils/helpers.ts
+++ b/src/utils/helpers.ts
@@ -50,11 +50,6 @@ export function generateGitHubWebUrl(
     newUrl = newUrl.replace('/pulls/', '/pull/');
   }
 
-  if (newUrl.indexOf('/releases/') !== -1) {
-    newUrl = newUrl.replace('/repos', '');
-    newUrl = newUrl.substring(0, newUrl.lastIndexOf('/'));
-  }
-
   if (userId) {
     const notificationReferrerId = generateNotificationReferrerId(
       notificationId,
@@ -73,6 +68,14 @@ const addHours = (date: string, hours: number) =>
 const queryString = (repo: string, title: string, lastUpdated: string) =>
   `${title} in:title repo:${repo} updated:>${addHours(lastUpdated, -2)}`;
 
+async function getReleaseTagWebUrl(notification: Notification, token: string) {
+  const response = await apiRequestAuth(notification.subject.url, 'GET', token);
+
+  return {
+    url: response.data.html_url,
+  };
+}
+
 async function getDiscussionUrl(
   notification: Notification,
   token: string,
@@ -155,16 +158,15 @@ export async function openInBrowser(
   notification: Notification,
   accounts: AuthState,
 ) {
-  if (notification.subject.url) {
-    const latestCommentId = getCommentId(
-      notification.subject.latest_comment_url,
-    );
-    openExternalLink(
-      generateGitHubWebUrl(
-        notification.subject.url,
-        notification.id,
-        accounts.user?.id,
-        latestCommentId ? '#issuecomment-' + latestCommentId : undefined,
+  if (notification.subject.type === 'Release') {
+    getReleaseTagWebUrl(notification, accounts.token).then(({ url }) =>
+      openExternalLink(
+        generateGitHubWebUrl(
+          url,
+          notification.id,
+          accounts.user?.id,
+          undefined,
+        ),
       ),
     );
   } else if (notification.subject.type === 'Discussion') {
@@ -181,5 +183,17 @@ export async function openInBrowser(
           ),
         ),
     );
+  } else if (notification.subject.url) {
+    const latestCommentId = getCommentId(
+      notification.subject.latest_comment_url,
+    );
+    openExternalLink(
+      generateGitHubWebUrl(
+        notification.subject.url,
+        notification.id,
+        accounts.user?.id,
+        latestCommentId ? '#issuecomment-' + latestCommentId : undefined,
+      ),
+    );
   }
 }


Test patch:
diff --git a/src/utils/helpers.test.ts b/src/utils/helpers.test.ts
index 3564e7f2..f9a60b45 100644
--- a/src/utils/helpers.test.ts
+++ b/src/utils/helpers.test.ts
@@ -59,7 +59,7 @@ describe('utils/helpers.ts', () => {
     it('should generate the GitHub url - non enterprise - (release)', () =>
       testGenerateUrl(
         `${URL.normal.api}/releases/3988077`,
-        `${URL.normal.default}/releases?${notificationReferrerId}`,
+        `${URL.normal.default}/releases/3988077?${notificationReferrerId}`,
       ));
 
     it('should generate the GitHub url - non enterprise - (discussion)', () =>
@@ -83,7 +83,7 @@ describe('utils/helpers.ts', () => {
     it('should generate the GitHub url - enterprise - (release)', () =>
       testGenerateUrl(
         `${URL.enterprise.api}/releases/1`,
-        `${URL.enterprise.default}/releases?${notificationReferrerId}`,
+        `${URL.enterprise.default}/releases/1?${notificationReferrerId}`,
       ));
 
     it('should generate the GitHub url - enterprise - (discussion)', () =>