Skip to content
Closed
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
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
"@types/react-dom": "19.2.2",
"@types/react-router-dom": "5.3.3",
"@types/semver": "7.7.1",
"identity-obj-proxy": "3.0.0",
"axios": "1.12.2",
"axios-cache-interceptor": "1.8.3",
"clsx": "2.1.1",
"concurrently": "9.2.1",
"copy-webpack-plugin": "13.0.1",
Expand All @@ -105,6 +105,7 @@
"graphql-tag": "2.12.6",
"html-webpack-plugin": "5.6.4",
"husky": "9.1.7",
"identity-obj-proxy": "3.0.0",
"jest": "30.2.0",
"jest-environment-jsdom": "30.2.0",
"mini-css-extract-plugin": "2.9.4",
Expand Down Expand Up @@ -138,4 +139,4 @@
"*": "biome check --fix --no-errors-on-unmatched",
"*.{js,ts,tsx}": "pnpm test --findRelatedTests --passWithNoTests --updateSnapshot"
}
}
}
31 changes: 31 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/renderer/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const Sidebar: FC = () => {

const refreshNotifications = () => {
navigate('/', { replace: true });

fetchNotifications();
};

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const Constants = {

ALL_READ_EMOJIS: ['🎉', '🎊', '🥳', '👏', '🙌', '😎', '🏖️', '🚀', '✨', '🏆'],

DEFAULT_FETCH_NOTIFICATIONS_INTERVAL_MS: 60 * 1000, // 1 minute
MIN_FETCH_NOTIFICATIONS_INTERVAL_MS: 60 * 1000, // 1 minute
DEFAULT_FETCH_NOTIFICATIONS_INTERVAL_MS: 5 * 1000, // 1 minute
MIN_FETCH_NOTIFICATIONS_INTERVAL_MS: 5 * 1000, // 1 minute
MAX_FETCH_NOTIFICATIONS_INTERVAL_MS: 60 * 60 * 1000, // 1 hour
FETCH_NOTIFICATIONS_INTERVAL_STEP_MS: 60 * 1000, // 1 minute

Expand Down
12 changes: 3 additions & 9 deletions src/renderer/hooks/useNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ export const useNotifications = (): NotificationsState => {
try {
await Promise.all(
readNotifications.map((notification) =>
markNotificationThreadAsRead(
notification.id,
notification.account.hostname,
notification.account.token,
),
markNotificationThreadAsRead(notification.account, notification.id),
),
);

Expand Down Expand Up @@ -149,9 +145,8 @@ export const useNotifications = (): NotificationsState => {
await Promise.all(
doneNotifications.map((notification) =>
markNotificationThreadAsDone(
notification.account,
notification.id,
notification.account.hostname,
notification.account.token,
),
),
);
Expand Down Expand Up @@ -184,9 +179,8 @@ export const useNotifications = (): NotificationsState => {

try {
await ignoreNotificationThreadSubscription(
notification.account,
notification.id,
notification.account.hostname,
notification.account.token,
);

if (state.settings.markAsDoneOnUnsubscribe) {
Expand Down
40 changes: 14 additions & 26 deletions src/renderer/utils/api/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
mockGitHubEnterpriseServerAccount,
mockToken,
} from '../../__mocks__/state-mocks';
import type { Hostname, Link, SettingsState, Token } from '../../types';
import type { Hostname, Link, SettingsState } from '../../types';
import * as logger from '../../utils/logger';
import {
getAuthenticatedUser,
Expand All @@ -31,7 +31,7 @@ describe('renderer/utils/api/client.ts', () => {

describe('getAuthenticatedUser', () => {
it('should fetch authenticated user - github', async () => {
await getAuthenticatedUser(mockGitHubHostname, mockToken);
await getAuthenticatedUser(mockGitHubCloudAccount);

expect(axios).toHaveBeenCalledWith({
url: 'https://api.github.com/user',
Expand All @@ -47,10 +47,10 @@ describe('renderer/utils/api/client.ts', () => {
});

it('should fetch authenticated user - enterprise', async () => {
await getAuthenticatedUser(mockEnterpriseHostname, mockToken);
await getAuthenticatedUser(mockGitHubEnterpriseServerAccount);

expect(axios).toHaveBeenCalledWith({
url: 'https://example.com/api/v3/user',
url: 'https://github.gitify.io/api/v3/user',
headers: {
Accept: 'application/json',
Authorization: 'token decrypted',
Expand Down Expand Up @@ -172,11 +172,7 @@ describe('renderer/utils/api/client.ts', () => {

describe('markNotificationThreadAsRead', () => {
it('should mark notification thread as read - github', async () => {
await markNotificationThreadAsRead(
mockThreadId,
mockGitHubHostname,
mockToken,
);
await markNotificationThreadAsRead(mockGitHubCloudAccount, mockThreadId);

expect(axios).toHaveBeenCalledWith({
url: `https://api.github.com/notifications/threads/${mockThreadId}`,
Expand All @@ -193,13 +189,12 @@ describe('renderer/utils/api/client.ts', () => {

it('should mark notification thread as read - enterprise', async () => {
await markNotificationThreadAsRead(
mockGitHubEnterpriseServerAccount,
mockThreadId,
mockEnterpriseHostname,
mockToken,
);

expect(axios).toHaveBeenCalledWith({
url: `https://example.com/api/v3/notifications/threads/${mockThreadId}`,
url: `https://github.gitify.io/api/v3/notifications/threads/${mockThreadId}`,
headers: {
Accept: 'application/json',
Authorization: 'token decrypted',
Expand All @@ -214,11 +209,7 @@ describe('renderer/utils/api/client.ts', () => {

describe('markNotificationThreadAsDone', () => {
it('should mark notification thread as done - github', async () => {
await markNotificationThreadAsDone(
mockThreadId,
mockGitHubHostname,
mockToken,
);
await markNotificationThreadAsDone(mockGitHubCloudAccount, mockThreadId);

expect(axios).toHaveBeenCalledWith({
url: `https://api.github.com/notifications/threads/${mockThreadId}`,
Expand All @@ -235,9 +226,8 @@ describe('renderer/utils/api/client.ts', () => {

it('should mark notification thread as done - enterprise', async () => {
await markNotificationThreadAsDone(
mockGitHubEnterpriseServerAccount,
mockThreadId,
mockEnterpriseHostname,
mockToken,
);

expect(axios).toHaveBeenCalledWith({
Expand All @@ -257,9 +247,8 @@ describe('renderer/utils/api/client.ts', () => {
describe('ignoreNotificationThreadSubscription', () => {
it('should ignore notification thread subscription - github', async () => {
await ignoreNotificationThreadSubscription(
mockGitHubCloudAccount,
mockThreadId,
mockGitHubHostname,
mockToken,
);

expect(axios).toHaveBeenCalledWith({
Expand All @@ -277,13 +266,12 @@ describe('renderer/utils/api/client.ts', () => {

it('should ignore notification thread subscription - enterprise', async () => {
await ignoreNotificationThreadSubscription(
mockGitHubEnterpriseServerAccount,
mockThreadId,
mockEnterpriseHostname,
mockToken,
);

expect(axios).toHaveBeenCalledWith({
url: `https://example.com/api/v3/notifications/threads/${mockThreadId}/subscription`,
url: `https://github.gitify.io/api/v3/notifications/threads/${mockThreadId}/subscription`,
headers: {
Accept: 'application/json',
Authorization: 'token decrypted',
Expand Down Expand Up @@ -312,8 +300,8 @@ describe('renderer/utils/api/client.ts', () => {
apiRequestAuthMock.mockResolvedValue(requestPromise);

const result = await getHtmlUrl(
mockGitHubCloudAccount,
'https://api.github.com/repos/gitify-app/notifications-test/issues/785' as Link,
'123' as Token,
);
expect(result).toBe(
'https://github.com/gitify-app/notifications-test/issues/785',
Expand All @@ -332,8 +320,8 @@ describe('renderer/utils/api/client.ts', () => {
apiRequestAuthMock.mockRejectedValue(mockError);

await getHtmlUrl(
mockGitHubCloudAccount,
'https://api.github.com/repos/gitify-app/gitify/issues/785' as Link,
'123' as Token,
);

expect(rendererLogErrorSpy).toHaveBeenCalledTimes(1);
Expand Down
Loading
Loading