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
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const LoginWithPersonalAccessTokenForm: FC<LoginWithPersonalAccessTokenFo
setErrors(newErrors);

if (!newErrors.hostname && !newErrors.token && !newErrors.username) {
verifyLoginCredentials(formData);
await verifyLoginCredentials(formData);
}
setIsVerifyingCredentials(false);
};
Expand Down
16 changes: 7 additions & 9 deletions src/renderer/hooks/useLogins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface LoginsState {
loginWithCli: (forge: Forge, hostname: Hostname) => Promise<void>;
loginWithOAuthApp: (forge: Forge, data: LoginOAuthWebOptions) => Promise<void>;
loginWithPersonalAccessToken: (data: LoginPersonalAccessTokenOptions) => Promise<void>;
logoutFromAccount: (account: Account) => Promise<void>;
logoutFromAccount: (account: Account) => void;
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ export const useLogins = (): LoginsState => {

const existingAccount = accounts.find((a) => a.hostname === hostname && a.method === method);
if (existingAccount) {
await removeAccountNotifications(existingAccount);
removeAccountNotifications(existingAccount);
}

await createAccount(method, token, hostname, forge);
Expand Down Expand Up @@ -128,9 +128,7 @@ export const useLogins = (): LoginsState => {
);
await createAccountInStore(cliAuth.authMethod, '' as Token, hostname, forge);

for (const account of existingAccounts) {
await removeAccountNotifications(account);
}
existingAccounts.forEach((account) => removeAccountNotifications(account));

await queryClient.invalidateQueries({ queryKey: notificationsKeys.all });
},
Expand All @@ -154,7 +152,7 @@ export const useLogins = (): LoginsState => {
(a) => a.hostname === authOptions.hostname && a.method === 'OAuth App',
);
if (existingAccount) {
await removeAccountNotifications(existingAccount);
removeAccountNotifications(existingAccount);
}

await createAccount('OAuth App', token, authOptions.hostname, forge);
Expand Down Expand Up @@ -183,7 +181,7 @@ export const useLogins = (): LoginsState => {
a.forge === resolvedForge,
);
if (existingAccount) {
await removeAccountNotifications(existingAccount);
removeAccountNotifications(existingAccount);
}

await createAccount('Personal Access Token', token, hostname, resolvedForge, username);
Expand All @@ -192,8 +190,8 @@ export const useLogins = (): LoginsState => {
);

const logoutFromAccount = useCallback(
async (account: Account) => {
await removeAccountNotifications(account);
(account: Account) => {
removeAccountNotifications(account);

removeAccount(account);
},
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/hooks/useNotifications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,8 @@ describe('renderer/hooks/useNotifications.ts', () => {

const enterpriseCount = mockMultipleAccountNotifications[1].notifications.length;

await act(async () => {
await result.current.removeAccountNotifications(mockGitHubCloudAccount);
await act(() => {
result.current.removeAccountNotifications(mockGitHubCloudAccount);
});

await waitFor(() => expect(result.current.notificationCount).toBe(enterpriseCount));
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/hooks/useNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface NotificationsState {
hasUnreadNotifications: boolean;

refetchNotifications: () => Promise<void>;
removeAccountNotifications: (account: Account) => Promise<void>;
removeAccountNotifications: (account: Account) => void;

markNotificationsAsRead: (notifications: GitifyNotification[]) => Promise<boolean>;
markNotificationsAsDone: (notifications: GitifyNotification[]) => Promise<boolean>;
Expand Down Expand Up @@ -305,7 +305,7 @@ export const useNotifications = ({
}, [withSideEffects, fetchIntervalMs, refetch]);

const removeAccountNotifications = useCallback(
async (account: Account) => {
(account: Account) => {
const accountUUID = getAccountUUID(account);

queryClient.setQueryData<AccountNotifications[]>(
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/routes/github/LoginWithOAuthApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const GitHubLoginWithOAuthAppRoute: FC = () => {
setErrors(newErrors);

if (!newErrors.hostname && !newErrors.clientId && !newErrors.clientSecret) {
verifyLoginCredentials(formData);
await verifyLoginCredentials(formData);
}
setIsVerifyingCredentials(false);
};
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/forges/github/handlers/checkSuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface CheckSuiteAttributes {
}

class CheckSuiteHandler extends DefaultHandler {
override async enrich(notification: GitifyNotification): Promise<Partial<GitifySubject>> {
override enrich(notification: GitifyNotification): Partial<GitifySubject> {
const state = getCheckSuiteAttributes(notification)?.status;

if (state) {
Expand Down
4 changes: 3 additions & 1 deletion src/renderer/utils/forges/github/handlers/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import type { NotificationTypeHandler } from './types';
export class DefaultHandler implements NotificationTypeHandler {
supportsMergedQueryEnrichment = false;

async enrich(_notification: GitifyNotification): Promise<Partial<GitifySubject>> {
enrich(
_notification: GitifyNotification,
): Partial<GitifySubject> | Promise<Partial<GitifySubject>> {
return {};
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/forges/github/handlers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface NotificationTypeHandler {
enrich(
notification: RawGitifyNotification,
fetchedData?: unknown,
): Promise<Partial<GitifySubject>>;
): Partial<GitifySubject> | Promise<Partial<GitifySubject>>;

/**
* Return the icon component for this notification type.
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/forges/github/handlers/workflowRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface WorkflowRunAttributes {
}

class WorkflowRunHandler extends DefaultHandler {
override async enrich(notification: GitifyNotification): Promise<Partial<GitifySubject>> {
override enrich(notification: GitifyNotification): Partial<GitifySubject> {
const state = getWorkflowRunAttributes(notification)?.status;

if (state) {
Expand Down
Loading