Skip to content

Commit 2c332be

Browse files
committed
refactor simplify
Signed-off-by: Adam Setch <[email protected]>
1 parent 52963ff commit 2c332be

File tree

7 files changed

+20
-21
lines changed

7 files changed

+20
-21
lines changed

src/renderer/components/notifications/AccountNotifications.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ export const AccountNotifications: FC<IAccountNotifications> = (
129129
{showAccountNotifications && (
130130
<>
131131
{props.error && <Oops error={props.error} fullHeight={false} />}
132+
132133
{!hasNotifications && !props.error && <AllRead fullHeight={false} />}
134+
133135
{isGroupByRepository(settings)
134136
? groupedNotifications.map(([repoSlug, repoNotifications]) => (
135137
<RepositoryNotifications

src/renderer/context/App.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ describe('renderer/context/App.tsx', () => {
5151
const markNotificationsAsReadMock = jest.fn();
5252
const markNotificationsAsDoneMock = jest.fn();
5353
const unsubscribeNotificationMock = jest.fn();
54-
const setTrayIconColorAndTitle = jest.fn();
5554

5655
const mockDefaultState = {
5756
auth: { accounts: [] },
@@ -64,7 +63,6 @@ describe('renderer/context/App.tsx', () => {
6463
markNotificationsAsRead: markNotificationsAsReadMock,
6564
markNotificationsAsDone: markNotificationsAsDoneMock,
6665
unsubscribeNotification: unsubscribeNotificationMock,
67-
setTrayIconColorAndTitle,
6866
});
6967
});
7068

src/renderer/hooks/useNotifications.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ export const useNotifications = (): NotificationsState => {
227227
return {
228228
status,
229229
globalError,
230-
notifications,
231230

232-
removeAccountNotifications,
231+
notifications,
233232
fetchNotifications,
233+
removeAccountNotifications,
234+
234235
markNotificationsAsRead,
235236
markNotificationsAsDone,
236237
unsubscribeNotification,

src/renderer/utils/notifications/native.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { APPLICATION } from '../../../shared/constants';
33
import type { Notification } from '../../typesGitHub';
44
import { generateGitHubWebUrl } from '../helpers';
55

6-
export const raiseNativeNotification = async (
7-
notifications: Notification[],
8-
) => {
6+
export async function raiseNativeNotification(notifications: Notification[]) {
97
let title: string;
108
let body: string;
119
let url: string = null;
@@ -23,4 +21,4 @@ export const raiseNativeNotification = async (
2321
}
2422

2523
return window.gitify.raiseNativeNotification(title, body, url);
26-
};
24+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export const raiseSoundNotification = async (volume: number) => {
2-
const path = await window.gitify.notificationSoundPath();
1+
export async function raiseSoundNotification(volume: number) {
2+
const path = await globalThis.gitify.notificationSoundPath();
33

44
const audio = new Audio(path);
55
audio.volume = volume;
66
audio.play();
7-
};
7+
}

src/renderer/utils/notifications/utils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ import { getAccountUUID } from '../auth/utils';
99
* @param notification - The notification to find the account index for
1010
* @returns The index of the account in the allNotifications array
1111
*/
12-
export const findAccountIndex = (
12+
export function findAccountIndex(
1313
allNotifications: AccountNotifications[],
1414
notification: Notification,
15-
): number => {
15+
): number {
1616
return allNotifications.findIndex(
1717
(accountNotifications) =>
1818
getAccountUUID(accountNotifications.account) ===
1919
getAccountUUID(notification.account),
2020
);
21-
};
21+
}
2222

2323
/**
2424
* Find notifications that exist in newNotifications but not in previousNotifications
2525
*/
26-
export const getNewNotifications = (
26+
export function getNewNotifications(
2727
previousNotifications: AccountNotifications[],
2828
newNotifications: AccountNotifications[],
29-
): Notification[] => {
29+
): Notification[] {
3030
return newNotifications.flatMap((accountNotifications) => {
3131
const accountPreviousNotifications = previousNotifications.find(
3232
(item) =>
@@ -46,4 +46,4 @@ export const getNewNotifications = (
4646
(notification) => !previousIds.has(notification.id),
4747
);
4848
});
49-
};
49+
}

src/renderer/utils/zoom.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ const MULTIPLIER = 2;
66
* @param percentage 0-150
77
* @returns zoomLevel -2 to 0.5
88
*/
9-
export const zoomPercentageToLevel = (percentage: number): number => {
9+
export function zoomPercentageToLevel(percentage: number): number {
1010
if (percentage === undefined) {
1111
return 0;
1212
}
1313

1414
return ((percentage - RECOMMENDED) * MULTIPLIER) / 100;
15-
};
15+
}
1616

1717
/**
1818
* Zoom level to percentage. 0 is the recommended zoom level (100%). If somehow the zoom level is not set, it will return 100, the default zoom percentage.
1919
* @param zoom -2 to 0.5
2020
* @returns percentage 0-150
2121
*/
22-
export const zoomLevelToPercentage = (zoom: number): number => {
22+
export function zoomLevelToPercentage(zoom: number): number {
2323
if (zoom === undefined) {
2424
return 100;
2525
}
2626

2727
return (zoom / MULTIPLIER) * 100 + RECOMMENDED;
28-
};
28+
}

0 commit comments

Comments
 (0)