Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/updater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ import { autoUpdater } from 'electron-updater';
describe('main/updater.ts', () => {
let menubar: Menubar;
class TestMenuBuilder extends MenuBuilder {
public setCheckForUpdatesMenuEnabled = vi.fn();
public setNoUpdateAvailableMenuVisibility = vi.fn();
public setUpdateAvailableMenuVisibility = vi.fn();
public setUpdateReadyForInstallMenuVisibility = vi.fn();
public override setCheckForUpdatesMenuEnabled = vi.fn();
public override setNoUpdateAvailableMenuVisibility = vi.fn();
public override setUpdateAvailableMenuVisibility = vi.fn();
public override setUpdateReadyForInstallMenuVisibility = vi.fn();
}

let menuBuilder: TestMenuBuilder;
Expand Down
10 changes: 4 additions & 6 deletions src/renderer/utils/notifications/handlers/checkSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export interface CheckSuiteAttributes {
}

class CheckSuiteHandler extends DefaultHandler {
readonly type = 'CheckSuite';

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
): Promise<Partial<GitifySubject>> {
Expand All @@ -49,7 +47,7 @@ class CheckSuiteHandler extends DefaultHandler {
return {};
}

iconType(notification: GitifyNotification): FC<OcticonProps> {
override iconType(notification: GitifyNotification): FC<OcticonProps> {
switch (notification.subject.state as GitifyCheckSuiteStatus) {
case 'CANCELLED':
return StopIcon;
Expand All @@ -64,7 +62,7 @@ class CheckSuiteHandler extends DefaultHandler {
}
}

iconColor(notification: GitifyNotification): IconColor {
override iconColor(notification: GitifyNotification): IconColor {
switch (notification.subject.state as GitifyCheckSuiteStatus) {
case 'SUCCESS':
return IconColor.GREEN;
Expand All @@ -75,7 +73,7 @@ class CheckSuiteHandler extends DefaultHandler {
}
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
return getCheckSuiteUrl(notification);
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/renderer/utils/notifications/handlers/commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import { DefaultHandler } from './default';
import { getNotificationAuthor } from './utils';

class CommitHandler extends DefaultHandler {
readonly type = 'Commit';

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
): Promise<Partial<GitifySubject>> {
Expand Down Expand Up @@ -65,7 +63,7 @@ class CommitHandler extends DefaultHandler {
};
}

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return GitCommitIcon;
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/utils/notifications/handlers/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ import {
IconColor,
type Link,
type SettingsState,
type SubjectType,
type UserType,
} from '../../../types';
import type { NotificationTypeHandler } from './types';

export class DefaultHandler implements NotificationTypeHandler {
type?: SubjectType;

supportsMergedQueryEnrichment?: boolean = false;
supportsMergedQueryEnrichment = false;

async enrich(
_notification: GitifyNotification,
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/utils/notifications/handlers/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

class DiscussionHandler extends DefaultHandler {
readonly type = 'Discussion';
override readonly supportsMergedQueryEnrichment = true;

readonly supportsMergedQueryEnrichment = true;

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
fetchedData?: DiscussionDetailsFragment,
Expand Down Expand Up @@ -82,7 +80,7 @@ class DiscussionHandler extends DefaultHandler {
};
}

iconType(notification: GitifyNotification): FC<OcticonProps> {
override iconType(notification: GitifyNotification): FC<OcticonProps> {
switch (notification.subject.state as GitifyDiscussionState) {
case 'DUPLICATE':
return DiscussionDuplicateIcon;
Expand All @@ -95,7 +93,7 @@ class DiscussionHandler extends DefaultHandler {
}
}

iconColor(notification: GitifyNotification): IconColor {
override iconColor(notification: GitifyNotification): IconColor {
switch (notification.subject.state) {
case 'ANSWERED':
return IconColor.GREEN;
Expand All @@ -106,7 +104,7 @@ class DiscussionHandler extends DefaultHandler {
}
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/discussions';
return url.href as Link;
Expand Down
15 changes: 0 additions & 15 deletions src/renderer/utils/notifications/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,3 @@ export function createNotificationHandler(
return defaultHandler;
}
}

export const handlers = {
checkSuiteHandler,
commitHandler,
discussionHandler,
issueHandler,
pullRequestHandler,
releaseHandler,
repositoryAdvisoryHandler,
repositoryDependabotAlertsThreadHandler,
repositoryInvitationHandler,
repositoryVulnerabilityAlertHandler,
workflowRunHandler,
defaultHandler,
};
12 changes: 5 additions & 7 deletions src/renderer/utils/notifications/handlers/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

class IssueHandler extends DefaultHandler {
readonly type = 'Issue';
override readonly supportsMergedQueryEnrichment = true;

readonly supportsMergedQueryEnrichment = true;

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
fetchedData?: IssueDetailsFragment,
Expand Down Expand Up @@ -66,7 +64,7 @@ class IssueHandler extends DefaultHandler {
};
}

iconType(notification: GitifyNotification): FC<OcticonProps> {
override iconType(notification: GitifyNotification): FC<OcticonProps> {
switch (notification.subject.state as GitifyIssueState) {
case 'CLOSED':
case 'COMPLETED':
Expand All @@ -81,7 +79,7 @@ class IssueHandler extends DefaultHandler {
}
}

iconColor(notification: GitifyNotification): IconColor {
override iconColor(notification: GitifyNotification): IconColor {
switch (notification.subject.state as GitifyIssueState) {
case 'OPEN':
case 'REOPENED':
Expand All @@ -95,7 +93,7 @@ class IssueHandler extends DefaultHandler {
}
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/issues';
return url.href as Link;
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/utils/notifications/handlers/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

class PullRequestHandler extends DefaultHandler {
readonly type = 'PullRequest' as const;
override readonly supportsMergedQueryEnrichment = true;

readonly supportsMergedQueryEnrichment = true;

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
fetchedData?: PullRequestDetailsFragment,
Expand Down Expand Up @@ -80,7 +78,7 @@ class PullRequestHandler extends DefaultHandler {
};
}

iconType(notification: GitifyNotification): FC<OcticonProps> {
override iconType(notification: GitifyNotification): FC<OcticonProps> {
switch (notification.subject.state as GitifyPullRequestState) {
case 'DRAFT':
return GitPullRequestDraftIcon;
Expand All @@ -95,7 +93,7 @@ class PullRequestHandler extends DefaultHandler {
}
}

iconColor(notification: GitifyNotification): IconColor {
override iconColor(notification: GitifyNotification): IconColor {
switch (notification.subject.state as GitifyPullRequestState) {
case 'OPEN':
return IconColor.GREEN;
Expand All @@ -110,7 +108,7 @@ class PullRequestHandler extends DefaultHandler {
}
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/pulls';
return url.href as Link;
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/utils/notifications/handlers/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import { DefaultHandler, defaultHandler } from './default';
import { getNotificationAuthor } from './utils';

class ReleaseHandler extends DefaultHandler {
readonly type = 'Release';

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
): Promise<Partial<GitifySubject>> {
Expand Down Expand Up @@ -52,11 +50,11 @@ class ReleaseHandler extends DefaultHandler {
};
}

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return TagIcon;
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/releases';
return url.href as Link;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ import type { GitifyNotification, Link, UserType } from '../../../types';
import { DefaultHandler, defaultHandler } from './default';

class RepositoryAdvisoryHandler extends DefaultHandler {
readonly type = 'RepositoryAdvisory';

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return AlertIcon;
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/security/advisories';
return url.href as Link;
}

defaultUserType(): UserType {
override defaultUserType(): UserType {
return 'Bot';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ import type { GitifyNotification, Link, UserType } from '../../../types';
import { DefaultHandler, defaultHandler } from './default';

class RepositoryDependabotAlertsThreadHandler extends DefaultHandler {
readonly type = 'RepositoryDependabotAlertsThread';

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return AlertIcon;
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/security/dependabot';
return url.href as Link;
}

defaultUserType(): UserType {
override defaultUserType(): UserType {
return 'Bot';
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import type { GitifyNotification, Link } from '../../../types';
import { DefaultHandler, defaultHandler } from './default';

class RepositoryInvitationHandler extends DefaultHandler {
readonly type = 'RepositoryInvitation';

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return MailIcon;
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
const url = new URL(defaultHandler.defaultUrl(notification));
url.pathname += '/invitations';
return url.href as Link;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import type { GitifyNotification, UserType } from '../../../types';
import { DefaultHandler } from './default';

class RepositoryVulnerabilityAlertHandler extends DefaultHandler {
readonly type = 'RepositoryVulnerabilityAlert';

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return AlertIcon;
}

defaultUserType(): UserType {
override defaultUserType(): UserType {
return 'Bot';
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/renderer/utils/notifications/handlers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ import type {
IconColor,
Link,
SettingsState,
SubjectType,
UserType,
} from '../../../types';

export interface NotificationTypeHandler {
readonly type?: SubjectType;

/**
* Whether the notification handler supports enrichment via merged GraphQL query.
*/
readonly supportsMergedQueryEnrichment?: boolean;
readonly supportsMergedQueryEnrichment: boolean;

/**
* Enriches a base notification with additional information (state, author, metrics, etc).
Expand Down
8 changes: 3 additions & 5 deletions src/renderer/utils/notifications/handlers/workflowRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export interface WorkflowRunAttributes {
}

class WorkflowRunHandler extends DefaultHandler {
readonly type = 'WorkflowRun';

async enrich(
override async enrich(
notification: GitifyNotification,
_settings: SettingsState,
): Promise<Partial<GitifySubject>> {
Expand All @@ -40,11 +38,11 @@ class WorkflowRunHandler extends DefaultHandler {
return {};
}

iconType(_notification: GitifyNotification): FC<OcticonProps> {
override iconType(_notification: GitifyNotification): FC<OcticonProps> {
return RocketIcon;
}

defaultUrl(notification: GitifyNotification): Link {
override defaultUrl(notification: GitifyNotification): Link {
return getWorkflowRunUrl(notification);
}
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,

"noImplicitOverride": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
Expand Down
Loading