Skip to content

Hotfix missing discussion items url #487

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

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
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
12 changes: 12 additions & 0 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export const NotificationRow: React.FC<IProps> = ({
const url = generateGitHubWebUrl(notification.subject.url);
shell.openExternal(url);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We know the first and third conditionals will always be true at this point of code execution, so we probably can clean this up a little bit:

    // Some Notification types from GitHub are missing urls in their subjects.
    if (notification.subject.url) {
      const url = generateGitHubWebUrl(notification.subject.url);
      shell.openExternal(url);
    // For discussions, we can at least send users to the main discussions page.
    } else if (notification.subject.type === SubjectType.Discussion) {
      const url = generateGitHubWebUrl(`${notification.repository.url}/discussions`);
      shell.openExternal(url);
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 😉

// TODO remove this future-legacy code when Github have pushed a fix (see #424)
if (
notification.subject.url === null &&
notification.subject.type === 'Discussion' &&
notification.repository.url
) {
const url = generateGitHubWebUrl(
`${notification.repository.url}/discussions`
);
shell.openExternal(url);
}
}, [notification]);

const unsubscribe = (event: React.MouseEvent<HTMLElement>) => {
Expand Down