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
3 changes: 2 additions & 1 deletion src/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { setAutoLaunch } from '../utils/comms';
import { useInterval } from '../hooks/useInterval';
import { useNotifications } from '../hooks/useNotifications';
import Constants from '../utils/constants';
import { generateGitHubAPIUrl } from '../utils/helpers';

const defaultAccounts: AuthState = {
token: null,
Expand Down Expand Up @@ -134,7 +135,7 @@ export const AppProvider = ({ children }: { children: React.ReactNode }) => {
const validateToken = useCallback(
async ({ token, hostname }: AuthTokenOptions) => {
await apiRequestAuth(
`https://api.${hostname}/notifications`,
`${generateGitHubAPIUrl(hostname)}notifications`,
'HEAD',
token
);
Expand Down
8 changes: 3 additions & 5 deletions src/hooks/useNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,14 @@ export const useNotifications = (): NotificationsState => {
if (!isGitHubLoggedIn) {
return;
}
const url = `https://api.${Constants.DEFAULT_AUTH_OPTIONS.hostname}/${endpointSuffix}`;
const url = `${generateGitHubAPIUrl(Constants.DEFAULT_AUTH_OPTIONS.hostname)}${endpointSuffix}`;
return apiRequestAuth(url, 'GET', accounts.token);
}

function getEnterpriseNotifications() {
return accounts.enterpriseAccounts.map((account) => {
const hostname = account.hostname;
const token = account.token;
const url = `https://${hostname}/api/v3/${endpointSuffix}`;
return apiRequestAuth(url, 'GET', token);
const url = `${generateGitHubAPIUrl(account.hostname)}${endpointSuffix}`;
return apiRequestAuth(url, 'GET', account.token);
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/utils/auth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { generateGitHubAPIUrl } from "./helpers";

const { remote } = require('electron');
const BrowserWindow = remote.BrowserWindow;

Expand Down Expand Up @@ -78,7 +80,7 @@ export const getUserData = async (
hostname: string
): Promise<User> => {
const response = await apiRequestAuth(
`https://api.${hostname}/user`,
`${generateGitHubAPIUrl(hostname)}user`,
'GET',
token
);
Expand Down