Skip to content

Commit dec0592

Browse files
committed
refactor(renderer): organize utils
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent f06df85 commit dec0592

34 files changed

Lines changed: 619 additions & 656 deletions

src/renderer/components/notifications/AccountNotifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
} from '../../types';
1717

1818
import { hasMultipleAccounts } from '../../utils/auth/utils';
19-
import { getChevronDetails } from '../../utils/helpers';
2019
import {
2120
groupNotificationsByRepository,
2221
isGroupByRepository,
@@ -27,6 +26,7 @@ import {
2726
openGitHubPulls,
2827
} from '../../utils/system/links';
2928
import { cn } from '../../utils/ui/cn';
29+
import { getChevronDetails } from '../../utils/ui/display';
3030
import { AllRead } from '../AllRead';
3131
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
3232
import { Oops } from '../Oops';

src/renderer/components/notifications/NotificationRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { HoverGroup } from '../primitives/HoverGroup';
1010

1111
import { type GitifyNotification, Opacity, Size } from '../../types';
1212

13-
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
13+
import { isMarkAsDoneFeatureSupported } from '../../utils/api/features';
1414
import { isGroupByDate } from '../../utils/notifications/group';
1515
import { shouldRemoveNotificationsFromState } from '../../utils/notifications/remove';
1616
import { openNotification } from '../../utils/system/links';

src/renderer/components/notifications/NotificationTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { Text } from '@primer/react';
44

55
import { useAppContext } from '../../hooks/useAppContext';
66

7-
import { parseInlineCode } from '../../utils/helpers';
87
import { cn } from '../../utils/ui/cn';
8+
import { parseInlineCode } from '../../utils/ui/display';
99

1010
interface NotificationTitleProps {
1111
title: string;

src/renderer/components/notifications/RepositoryNotifications.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { HoverGroup } from '../primitives/HoverGroup';
1010

1111
import { type GitifyNotification, Opacity, Size } from '../../types';
1212

13-
import { isMarkAsDoneFeatureSupported } from '../../utils/features';
14-
import { getChevronDetails } from '../../utils/helpers';
13+
import { isMarkAsDoneFeatureSupported } from '../../utils/api/features';
1514
import { shouldRemoveNotificationsFromState } from '../../utils/notifications/remove';
1615
import { openRepository } from '../../utils/system/links';
1716
import { cn } from '../../utils/ui/cn';
17+
import { getChevronDetails } from '../../utils/ui/display';
1818
import { AvatarWithFallback } from '../avatars/AvatarWithFallback';
1919
import { NotificationRow } from './NotificationRow';
2020

src/renderer/hooks/useNotifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import {
1414
markNotificationThreadAsDone,
1515
markNotificationThreadAsRead,
1616
} from '../utils/api/client';
17+
import { isMarkAsDoneFeatureSupported } from '../utils/api/features';
1718
import { getAccountUUID } from '../utils/auth/utils';
1819
import {
1920
areAllAccountErrorsSame,
2021
doesAllAccountsHaveErrors,
2122
} from '../utils/core/errors';
2223
import { rendererLogError } from '../utils/core/logger';
23-
import { isMarkAsDoneFeatureSupported } from '../utils/features';
2424
import {
2525
getAllNotifications,
2626
getNotificationCount,

src/renderer/utils/__snapshots__/reason.test.ts.snap

Lines changed: 0 additions & 113 deletions
This file was deleted.

src/renderer/utils/api/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import type {
1717
MarkNotificationThreadAsReadResponse,
1818
} from './types';
1919

20-
import { isAnsweredDiscussionFeatureSupported } from '../features';
2120
import { createNotificationHandler } from '../notifications/handlers';
21+
import { isAnsweredDiscussionFeatureSupported } from './features';
2222
import {
2323
FetchDiscussionByNumberDocument,
2424
type FetchDiscussionByNumberQuery,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {
22
mockGitHubCloudAccount,
33
mockGitHubEnterpriseServerAccount,
4-
} from '../__mocks__/account-mocks';
4+
} from '../../__mocks__/account-mocks';
55

66
import {
77
isAnsweredDiscussionFeatureSupported,
88
isMarkAsDoneFeatureSupported,
99
} from './features';
1010

11-
describe('renderer/utils/features.ts', () => {
11+
describe('renderer/utils/api/features.ts', () => {
1212
describe('isMarkAsDoneFeatureSupported', () => {
1313
it('should return true for GitHub Cloud', () => {
1414
expect(isMarkAsDoneFeatureSupported(mockGitHubCloudAccount)).toBe(true);
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import semver from 'semver';
22

3-
import type { Account } from '../types';
3+
import type { Account } from '../../types';
44

5-
import { isEnterpriseServerHost } from './helpers';
5+
import { isEnterpriseServerHost } from '../auth/platform';
66

77
/**
88
* Check if the "Mark as done" feature is supported for the given account.
99
*
1010
* GitHub Cloud or GitHub Enterprise Server 3.13 or newer is required to support this feature.
1111
*/
12-
1312
export function isMarkAsDoneFeatureSupported(account: Account): boolean {
1413
if (isEnterpriseServerHost(account.hostname)) {
1514
if (account.version) {
@@ -21,12 +20,12 @@ export function isMarkAsDoneFeatureSupported(account: Account): boolean {
2120

2221
return true;
2322
}
23+
2424
/**
2525
* Check if the "answered" discussions are supported for the given account.
2626
*
2727
* GitHub Cloud or GitHub Enterprise Server 3.12 or newer is required to support this feature.
2828
*/
29-
3029
export function isAnsweredDiscussionFeatureSupported(
3130
account: Account,
3231
): boolean {

src/renderer/utils/api/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
} from '../../types';
1313
import type { RawGitHubNotification } from './types';
1414

15-
import { getReasonDetails } from '../reason';
15+
import { getReasonDetails } from '../notifications/reason';
1616

1717
/**
1818
* Transform all raw notifications from Atlassian types to Atlassify types.

0 commit comments

Comments
 (0)