Skip to content

Commit 0386214

Browse files
committed
refactor: handler overrides
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent c5402eb commit 0386214

14 files changed

Lines changed: 53 additions & 67 deletions

src/main/updater.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ import { autoUpdater } from 'electron-updater';
6161
describe('main/updater.ts', () => {
6262
let menubar: Menubar;
6363
class TestMenuBuilder extends MenuBuilder {
64-
public setCheckForUpdatesMenuEnabled = vi.fn();
65-
public setNoUpdateAvailableMenuVisibility = vi.fn();
66-
public setUpdateAvailableMenuVisibility = vi.fn();
67-
public setUpdateReadyForInstallMenuVisibility = vi.fn();
64+
public override setCheckForUpdatesMenuEnabled = vi.fn();
65+
public override setNoUpdateAvailableMenuVisibility = vi.fn();
66+
public override setUpdateAvailableMenuVisibility = vi.fn();
67+
public override setUpdateReadyForInstallMenuVisibility = vi.fn();
6868
}
6969

7070
let menuBuilder: TestMenuBuilder;

src/renderer/utils/notifications/handlers/checkSuite.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export interface CheckSuiteAttributes {
3030
}
3131

3232
class CheckSuiteHandler extends DefaultHandler {
33-
readonly type = 'CheckSuite';
33+
override readonly type = 'CheckSuite';
3434

35-
async enrich(
35+
override async enrich(
3636
notification: GitifyNotification,
3737
_settings: SettingsState,
3838
): Promise<Partial<GitifySubject>> {
@@ -49,7 +49,7 @@ class CheckSuiteHandler extends DefaultHandler {
4949
return {};
5050
}
5151

52-
iconType(notification: GitifyNotification): FC<OcticonProps> {
52+
override iconType(notification: GitifyNotification): FC<OcticonProps> {
5353
switch (notification.subject.state as GitifyCheckSuiteStatus) {
5454
case 'CANCELLED':
5555
return StopIcon;
@@ -64,7 +64,7 @@ class CheckSuiteHandler extends DefaultHandler {
6464
}
6565
}
6666

67-
iconColor(notification: GitifyNotification): IconColor {
67+
override iconColor(notification: GitifyNotification): IconColor {
6868
switch (notification.subject.state as GitifyCheckSuiteStatus) {
6969
case 'SUCCESS':
7070
return IconColor.GREEN;
@@ -75,7 +75,7 @@ class CheckSuiteHandler extends DefaultHandler {
7575
}
7676
}
7777

78-
defaultUrl(notification: GitifyNotification): Link {
78+
override defaultUrl(notification: GitifyNotification): Link {
7979
return getCheckSuiteUrl(notification);
8080
}
8181
}

src/renderer/utils/notifications/handlers/commit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import { DefaultHandler } from './default';
1818
import { getNotificationAuthor } from './utils';
1919

2020
class CommitHandler extends DefaultHandler {
21-
readonly type = 'Commit';
21+
override readonly type = 'Commit';
2222

23-
async enrich(
23+
override async enrich(
2424
notification: GitifyNotification,
2525
_settings: SettingsState,
2626
): Promise<Partial<GitifySubject>> {
@@ -65,7 +65,7 @@ class CommitHandler extends DefaultHandler {
6565
};
6666
}
6767

68-
iconType(_notification: GitifyNotification): FC<OcticonProps> {
68+
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
6969
return GitCommitIcon;
7070
}
7171
}

src/renderer/utils/notifications/handlers/discussion.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import { DefaultHandler, defaultHandler } from './default';
2929
import { getNotificationAuthor } from './utils';
3030

3131
class DiscussionHandler extends DefaultHandler {
32-
readonly type = 'Discussion';
32+
override readonly type = 'Discussion';
3333

34-
readonly supportsMergedQueryEnrichment = true;
34+
override readonly supportsMergedQueryEnrichment = true;
3535

36-
async enrich(
36+
override async enrich(
3737
notification: GitifyNotification,
3838
_settings: SettingsState,
3939
fetchedData?: DiscussionDetailsFragment,
@@ -82,7 +82,7 @@ class DiscussionHandler extends DefaultHandler {
8282
};
8383
}
8484

85-
iconType(notification: GitifyNotification): FC<OcticonProps> {
85+
override iconType(notification: GitifyNotification): FC<OcticonProps> {
8686
switch (notification.subject.state as GitifyDiscussionState) {
8787
case 'DUPLICATE':
8888
return DiscussionDuplicateIcon;
@@ -95,7 +95,7 @@ class DiscussionHandler extends DefaultHandler {
9595
}
9696
}
9797

98-
iconColor(notification: GitifyNotification): IconColor {
98+
override iconColor(notification: GitifyNotification): IconColor {
9999
switch (notification.subject.state) {
100100
case 'ANSWERED':
101101
return IconColor.GREEN;
@@ -106,7 +106,7 @@ class DiscussionHandler extends DefaultHandler {
106106
}
107107
}
108108

109-
defaultUrl(notification: GitifyNotification): Link {
109+
override defaultUrl(notification: GitifyNotification): Link {
110110
const url = new URL(defaultHandler.defaultUrl(notification));
111111
url.pathname += '/discussions';
112112
return url.href as Link;

src/renderer/utils/notifications/handlers/index.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,3 @@ export function createNotificationHandler(
4444
return defaultHandler;
4545
}
4646
}
47-
48-
export const handlers = {
49-
checkSuiteHandler,
50-
commitHandler,
51-
discussionHandler,
52-
issueHandler,
53-
pullRequestHandler,
54-
releaseHandler,
55-
repositoryAdvisoryHandler,
56-
repositoryDependabotAlertsThreadHandler,
57-
repositoryInvitationHandler,
58-
repositoryVulnerabilityAlertHandler,
59-
workflowRunHandler,
60-
defaultHandler,
61-
};

src/renderer/utils/notifications/handlers/issue.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import { DefaultHandler, defaultHandler } from './default';
2323
import { getNotificationAuthor } from './utils';
2424

2525
class IssueHandler extends DefaultHandler {
26-
readonly type = 'Issue';
26+
override readonly type = 'Issue';
2727

28-
readonly supportsMergedQueryEnrichment = true;
28+
override readonly supportsMergedQueryEnrichment = true;
2929

30-
async enrich(
30+
override async enrich(
3131
notification: GitifyNotification,
3232
_settings: SettingsState,
3333
fetchedData?: IssueDetailsFragment,
@@ -66,7 +66,7 @@ class IssueHandler extends DefaultHandler {
6666
};
6767
}
6868

69-
iconType(notification: GitifyNotification): FC<OcticonProps> {
69+
override iconType(notification: GitifyNotification): FC<OcticonProps> {
7070
switch (notification.subject.state as GitifyIssueState) {
7171
case 'CLOSED':
7272
case 'COMPLETED':
@@ -81,7 +81,7 @@ class IssueHandler extends DefaultHandler {
8181
}
8282
}
8383

84-
iconColor(notification: GitifyNotification): IconColor {
84+
override iconColor(notification: GitifyNotification): IconColor {
8585
switch (notification.subject.state as GitifyIssueState) {
8686
case 'OPEN':
8787
case 'REOPENED':
@@ -95,7 +95,7 @@ class IssueHandler extends DefaultHandler {
9595
}
9696
}
9797

98-
defaultUrl(notification: GitifyNotification): Link {
98+
override defaultUrl(notification: GitifyNotification): Link {
9999
const url = new URL(defaultHandler.defaultUrl(notification));
100100
url.pathname += '/issues';
101101
return url.href as Link;

src/renderer/utils/notifications/handlers/pullRequest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import { DefaultHandler, defaultHandler } from './default';
2929
import { getNotificationAuthor } from './utils';
3030

3131
class PullRequestHandler extends DefaultHandler {
32-
readonly type = 'PullRequest' as const;
32+
override readonly type = 'PullRequest' as const;
3333

34-
readonly supportsMergedQueryEnrichment = true;
34+
override readonly supportsMergedQueryEnrichment = true;
3535

36-
async enrich(
36+
override async enrich(
3737
notification: GitifyNotification,
3838
_settings: SettingsState,
3939
fetchedData?: PullRequestDetailsFragment,
@@ -80,7 +80,7 @@ class PullRequestHandler extends DefaultHandler {
8080
};
8181
}
8282

83-
iconType(notification: GitifyNotification): FC<OcticonProps> {
83+
override iconType(notification: GitifyNotification): FC<OcticonProps> {
8484
switch (notification.subject.state as GitifyPullRequestState) {
8585
case 'DRAFT':
8686
return GitPullRequestDraftIcon;
@@ -95,7 +95,7 @@ class PullRequestHandler extends DefaultHandler {
9595
}
9696
}
9797

98-
iconColor(notification: GitifyNotification): IconColor {
98+
override iconColor(notification: GitifyNotification): IconColor {
9999
switch (notification.subject.state as GitifyPullRequestState) {
100100
case 'OPEN':
101101
return IconColor.GREEN;
@@ -110,7 +110,7 @@ class PullRequestHandler extends DefaultHandler {
110110
}
111111
}
112112

113-
defaultUrl(notification: GitifyNotification): Link {
113+
override defaultUrl(notification: GitifyNotification): Link {
114114
const url = new URL(defaultHandler.defaultUrl(notification));
115115
url.pathname += '/pulls';
116116
return url.href as Link;

src/renderer/utils/notifications/handlers/release.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import { DefaultHandler, defaultHandler } from './default';
1919
import { getNotificationAuthor } from './utils';
2020

2121
class ReleaseHandler extends DefaultHandler {
22-
readonly type = 'Release';
22+
override readonly type = 'Release';
2323

24-
async enrich(
24+
override async enrich(
2525
notification: GitifyNotification,
2626
_settings: SettingsState,
2727
): Promise<Partial<GitifySubject>> {
@@ -52,11 +52,11 @@ class ReleaseHandler extends DefaultHandler {
5252
};
5353
}
5454

55-
iconType(_notification: GitifyNotification): FC<OcticonProps> {
55+
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
5656
return TagIcon;
5757
}
5858

59-
defaultUrl(notification: GitifyNotification): Link {
59+
override defaultUrl(notification: GitifyNotification): Link {
6060
const url = new URL(defaultHandler.defaultUrl(notification));
6161
url.pathname += '/releases';
6262
return url.href as Link;

src/renderer/utils/notifications/handlers/repositoryAdvisory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import type { GitifyNotification, Link, UserType } from '../../../types';
77
import { DefaultHandler, defaultHandler } from './default';
88

99
class RepositoryAdvisoryHandler extends DefaultHandler {
10-
readonly type = 'RepositoryAdvisory';
10+
override readonly type = 'RepositoryAdvisory';
1111

12-
iconType(_notification: GitifyNotification): FC<OcticonProps> {
12+
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
1313
return AlertIcon;
1414
}
1515

16-
defaultUrl(notification: GitifyNotification): Link {
16+
override defaultUrl(notification: GitifyNotification): Link {
1717
const url = new URL(defaultHandler.defaultUrl(notification));
1818
url.pathname += '/security/advisories';
1919
return url.href as Link;
2020
}
2121

22-
defaultUserType(): UserType {
22+
override defaultUserType(): UserType {
2323
return 'Bot';
2424
}
2525
}

src/renderer/utils/notifications/handlers/repositoryDependabotAlertsThread.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ import type { GitifyNotification, Link, UserType } from '../../../types';
88
import { DefaultHandler, defaultHandler } from './default';
99

1010
class RepositoryDependabotAlertsThreadHandler extends DefaultHandler {
11-
readonly type = 'RepositoryDependabotAlertsThread';
11+
override readonly type = 'RepositoryDependabotAlertsThread';
1212

13-
iconType(_notification: GitifyNotification): FC<OcticonProps> {
13+
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
1414
return AlertIcon;
1515
}
1616

17-
defaultUrl(notification: GitifyNotification): Link {
17+
override defaultUrl(notification: GitifyNotification): Link {
1818
const url = new URL(defaultHandler.defaultUrl(notification));
1919
url.pathname += '/security/dependabot';
2020
return url.href as Link;
2121
}
2222

23-
defaultUserType(): UserType {
23+
override defaultUserType(): UserType {
2424
return 'Bot';
2525
}
2626
}

0 commit comments

Comments
 (0)