Skip to content

Commit

Permalink
Merge branch 'main' into refactor/rename-repository-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 18, 2024
2 parents 94a7a7f + 3409139 commit 68becc8
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 30 deletions.
8 changes: 5 additions & 3 deletions src/components/AccountNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ import {
ChevronLeftIcon,
ChevronUpIcon,
} from '@primer/octicons-react';
import { useState } from 'react';
import { type FC, useState } from 'react';
import type { Account } from '../types';
import type { Notification } from '../typesGitHub';
import { openAccountProfile } from '../utils/links';
import { RepositoryNotifications } from './RepositoryNotifications';
import { PlatformIcon } from './icons/PlatformIcon';

interface IProps {
interface IAccountNotifications {
account: Account;
notifications: Notification[];
showAccountHostname: boolean;
}

export const AccountNotifications = (props: IProps) => {
export const AccountNotifications: FC<IAccountNotifications> = (
props: IAccountNotifications,
) => {
const { account, showAccountHostname, notifications } = props;

const groupedNotifications = Object.values(
Expand Down
11 changes: 9 additions & 2 deletions src/components/AllRead.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { render } from '@testing-library/react';
import { AllRead } from './AllRead';
import { mockMathRandom } from './test-utils';

describe('components/AllRead.tsx', () => {
const originalMathRandom = Math.random;

// The read emoji randomly rotates, but then the snapshots would never match
// Have to make it consistent so the emojis are always the same
mockMathRandom(0.1);
beforeEach(() => {
global.Math.random = jest.fn(() => 0.1);
});

afterEach(() => {
global.Math.random = originalMathRandom;
});

it('should render itself & its children', () => {
const tree = render(<AllRead />);
Expand Down
4 changes: 2 additions & 2 deletions src/components/AllRead.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { type FC, useMemo } from 'react';
import { Constants } from '../utils/constants';

export const AllRead = () => {
export const AllRead: FC = () => {
const emoji = useMemo(
() =>
Constants.ALL_READ_EMOJIS[
Expand Down
4 changes: 2 additions & 2 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ArrowLeftIcon } from '@primer/octicons-react';
import type { ReactNode } from 'react';
import type { FC, ReactNode } from 'react';
import { useNavigate } from 'react-router-dom';

interface IHeader {
children: ReactNode;
}

export const Header = ({ children }: IHeader) => {
export const Header: FC<IHeader> = ({ children }: IHeader) => {
const navigate = useNavigate();
return (
<div className="mx-8 mt-2 flex items-center justify-between py-2">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Loading.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import NProgress from 'nprogress';
import { useContext, useEffect } from 'react';
import { type FC, useContext, useEffect } from 'react';
import { AppContext } from '../context/App';

export const Loading = () => {
export const Loading: FC = () => {
const { status } = useContext(AppContext);

useEffect(() => {
Expand Down
11 changes: 9 additions & 2 deletions src/components/Logo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
interface IProps {
import type { FC } from 'react';

interface ILogo {
isDark?: boolean;
onClick?: () => void;
className?: string;
Expand All @@ -10,7 +12,12 @@ const LIGHT_GRADIENT_END = '#FFFFFF';
const DARK_GRADIENT_START = '#22283B';
const DARK_GRADIENT_END = '#555B6E';

export const Logo = ({ isDark, onClick, className = '', ...props }: IProps) => (
export const Logo: FC<ILogo> = ({
isDark,
onClick,
className = '',
...props
}: ILogo) => (
<svg
className={className}
onClick={() => onClick?.()}
Expand Down
6 changes: 4 additions & 2 deletions src/components/NotificationRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import { openNotification, openUserProfile } from '../utils/links';
import { formatReason } from '../utils/reason';
import { PillButton } from './buttons/PillButton';

interface IProps {
interface INotificationRow {
notification: Notification;
}

export const NotificationRow: FC<IProps> = ({ notification }) => {
export const NotificationRow: FC<INotificationRow> = ({
notification,
}: INotificationRow) => {
const {
settings,
removeNotificationFromState,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Oops.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type FC, useMemo } from 'react';
import type { GitifyError } from '../types';

interface IProps {
interface IOops {
error: GitifyError;
}

export const Oops: FC<IProps> = ({ error }) => {
export const Oops: FC<IOops> = ({ error }: IOops) => {
const emoji = useMemo(
() => error.emojis[Math.floor(Math.random() * error.emojis.length)],
[error],
Expand Down
4 changes: 2 additions & 2 deletions src/components/RepositoryNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import type { Notification } from '../typesGitHub';
import { openRepository } from '../utils/links';
import { NotificationRow } from './NotificationRow';

interface IProps {
interface IRepositoryNotifications {
repoNotifications: Notification[];
repoName: string;
}

export const RepositoryNotifications: FC<IProps> = ({
export const RepositoryNotifications: FC<IRepositoryNotifications> = ({
repoName,
repoNotifications,
}) => {
Expand Down
11 changes: 0 additions & 11 deletions src/components/test-utils.ts

This file was deleted.

0 comments on commit 68becc8

Please sign in to comment.