Skip to content

Commit

Permalink
Merge 4ef9591 into 5317433
Browse files Browse the repository at this point in the history
  • Loading branch information
setchy committed Jun 18, 2024
2 parents 5317433 + 4ef9591 commit e08a108
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions src/utils/auth/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import { Constants } from '../constants';
import { getPlatformFromHostname } from '../helpers';
import type { AuthMethod, AuthResponse, AuthTokenResponse } from './types';

export const authGitHub = (
export function authGitHub(
authOptions = Constants.DEFAULT_AUTH_OPTIONS,
): Promise<AuthResponse> => {
): Promise<AuthResponse> {
return new Promise((resolve, reject) => {
// Build the OAuth consent page URL
const authWindow = new BrowserWindow({
Expand Down Expand Up @@ -83,12 +83,12 @@ export const authGitHub = (
handleCallback(url as Link);
});
});
};
}

export const getUserData = async (
export async function getUserData(
token: Token,
hostname: Hostname,
): Promise<GitifyUser> => {
): Promise<GitifyUser> {
const response: UserDetails = (await getAuthenticatedUser(hostname, token))
.data;

Expand All @@ -97,12 +97,12 @@ export const getUserData = async (
login: response.login,
name: response.name,
};
};
}

export const getToken = async (
export async function getToken(
authCode: AuthCode,
authOptions = Constants.DEFAULT_AUTH_OPTIONS,
): Promise<AuthTokenResponse> => {
): Promise<AuthTokenResponse> {
const url =
`https://${authOptions.hostname}/login/oauth/access_token` as Link;
const data = {
Expand All @@ -116,7 +116,7 @@ export const getToken = async (
hostname: authOptions.hostname,
token: response.data.access_token,
};
};
}

export function addAccount(
auth: AuthState,
Expand Down
4 changes: 2 additions & 2 deletions src/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { openNotification } from './links';
import { isWindows } from './platform';
import { getGitifySubjectDetails } from './subject';

export const setTrayIconColor = (notifications: AccountNotifications[]) => {
export function setTrayIconColor(notifications: AccountNotifications[]) {
const allNotificationsCount = getNotificationCount(notifications);

updateTrayIcon(allNotificationsCount);
};
}

export function getNotificationCount(notifications: AccountNotifications[]) {
return notifications.reduce(
Expand Down
6 changes: 3 additions & 3 deletions src/utils/remove-notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import type { AccountNotifications, SettingsState } from '../types';
import type { Notification } from '../typesGitHub';
import { getAccountUUID } from './auth/utils';

export const removeNotification = (
export function removeNotification(
settings: SettingsState,
notification: Notification,
notifications: AccountNotifications[],
): AccountNotifications[] => {
): AccountNotifications[] {
if (settings.delayNotificationState) {
return notifications;
}
Expand All @@ -31,4 +31,4 @@ export const removeNotification = (
}

return notifications;
};
}
6 changes: 3 additions & 3 deletions src/utils/remove-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type { AccountNotifications } from '../types';
import type { Notification } from '../typesGitHub';
import { getAccountUUID } from './auth/utils';

export const removeNotifications = (
export function removeNotifications(
notification: Notification,
notifications: AccountNotifications[],
): AccountNotifications[] => {
): AccountNotifications[] {
const repoSlug = notification.repository.full_name;

const accountIndex = notifications.findIndex(
Expand All @@ -26,4 +26,4 @@ export const removeNotifications = (
}

return notifications;
};
}
12 changes: 6 additions & 6 deletions src/utils/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export function getTheme(): Theme {
return Theme.LIGHT;
}

export const setLightMode = () => {
export function setLightMode() {
document.querySelector('html').classList.remove('dark');
};
}

export const setDarkMode = () => {
export function setDarkMode() {
document.querySelector('html').classList.add('dark');
};
}

export const setTheme = (mode?: Theme) => {
export function setTheme(mode?: Theme) {
switch (mode) {
case Theme.LIGHT:
setLightMode();
Expand All @@ -33,4 +33,4 @@ export const setTheme = (mode?: Theme) => {
setLightMode();
}
}
};
}

0 comments on commit e08a108

Please sign in to comment.