Skip to content

Commit

Permalink
pass account instead of hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 8, 2024
1 parent ba81d6d commit 7c9c84e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const AccountNotifications = (props: IProps) => {
return (
<RepositoryNotifications
key={repoSlug}
hostname={account.hostname}
account={account}
repoName={repoSlug}
repoNotifications={repoNotifications}
/>
Expand Down
44 changes: 24 additions & 20 deletions src/components/NotificationRow.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { shell } from 'electron';
import { mockAuth, mockSettings } from '../__mocks__/state-mocks';
import {
mockAuth,
mockGitHubCloudAccount,
mockSettings,
} from '../__mocks__/state-mocks';
import { AppContext } from '../context/App';
import type { Milestone, UserType } from '../typesGitHub';
import { mockSingleNotification } from '../utils/api/__mocks__/response-mocks';
Expand All @@ -23,7 +27,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -44,7 +48,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -65,7 +69,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -88,7 +92,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -115,7 +119,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -140,7 +144,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -167,7 +171,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -192,7 +196,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -217,7 +221,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -244,7 +248,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand Down Expand Up @@ -274,7 +278,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand Down Expand Up @@ -302,7 +306,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

const tree = render(
Expand All @@ -325,7 +329,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand All @@ -350,7 +354,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand All @@ -375,7 +379,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand All @@ -400,7 +404,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand All @@ -423,7 +427,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand All @@ -443,7 +447,7 @@ describe('components/NotificationRow.tsx', () => {

const props = {
notification: mockSingleNotification,
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand Down Expand Up @@ -475,7 +479,7 @@ describe('components/NotificationRow.tsx', () => {
reviews: null,
},
},
hostname: 'github.com',
account: mockGitHubCloudAccount,
};

render(
Expand Down
6 changes: 3 additions & 3 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from 'react';

import { AppContext } from '../context/App';
import { IconColor } from '../types';
import { type Account, IconColor } from '../types';
import type { Notification } from '../typesGitHub';
import { openExternalLink } from '../utils/comms';
import Constants from '../utils/constants';
Expand All @@ -34,11 +34,11 @@ import {
import { formatReason } from '../utils/reason';

interface IProps {
hostname: string;
account: Account;
notification: Notification;
}

export const NotificationRow: FC<IProps> = ({ notification, hostname }) => {
export const NotificationRow: FC<IProps> = ({ notification, account }) => {
const {
auth,
settings,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Repository.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { fireEvent, render, screen } from '@testing-library/react';
import { shell } from 'electron';
import { mockGitHubCloudAccount } from '../__mocks__/state-mocks';
import { AppContext } from '../context/App';
import {
mockGitHubNotifications,
Expand All @@ -16,7 +17,7 @@ describe('components/Repository.tsx', () => {
const markRepoNotificationsDone = jest.fn();

const props = {
hostname: 'github.com',
account: mockGitHubCloudAccount,
repoName: 'gitify-app/notifications-test',
repoNotifications: mockGitHubNotifications,
};
Expand Down
11 changes: 6 additions & 5 deletions src/components/Repository.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import { CheckIcon, MarkGithubIcon, ReadIcon } from '@primer/octicons-react';
import { type FC, useCallback, useContext } from 'react';
import { CSSTransition, TransitionGroup } from 'react-transition-group';
import { AppContext } from '../context/App';
import type { Account } from '../types';
import type { Notification } from '../typesGitHub';
import { openExternalLink } from '../utils/comms';
import { NotificationRow } from './NotificationRow';

interface IProps {
hostname: string;
account: Account;
repoNotifications: Notification[];
repoName: string;
}

export const RepositoryNotifications: FC<IProps> = ({
repoName,
repoNotifications,
hostname,
account,
}) => {
const { markRepoNotifications, markRepoNotificationsDone } =
useContext(AppContext);
Expand All @@ -27,11 +28,11 @@ export const RepositoryNotifications: FC<IProps> = ({

const markRepoAsRead = useCallback(() => {
markRepoNotifications(repoNotifications[0]);
}, [repoNotifications, hostname]);
}, [repoNotifications, account]);

const markRepoAsDone = useCallback(() => {
markRepoNotificationsDone(repoNotifications[0]);
}, [repoNotifications, hostname]);
}, [repoNotifications, account]);

const avatarUrl = repoNotifications[0].repository.owner.avatar_url;
const repoSlug = repoNotifications[0].repository.full_name;
Expand Down Expand Up @@ -86,7 +87,7 @@ export const RepositoryNotifications: FC<IProps> = ({
<CSSTransition key={obj.id} timeout={250} classNames="notification">
<NotificationRow
key={obj.id}
hostname={hostname}
account={account}
notification={obj}
/>
</CSSTransition>
Expand Down

0 comments on commit 7c9c84e

Please sign in to comment.