diff --git a/README.md b/README.md index ebada73..c7b815f 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ NOW - [ ] purchase and setup Apple developer account - [ ] setup brew cask definition - [ ] update test snapshot for "date updated at" to mock result -- [ ] count total, add + when there are more paged results - [ ] refactor account header settings from settings -> account object SOON diff --git a/src/utils/api/client.ts b/src/utils/api/client.ts index b7492d6..c6eaab3 100644 --- a/src/utils/api/client.ts +++ b/src/utils/api/client.ts @@ -2,6 +2,7 @@ import type { AxiosPromise } from 'axios'; import gql from 'graphql-tag'; import { print } from 'graphql/language/printer'; import type { Account, SettingsState } from '../../types'; +import { Constants } from '../constants'; import { apiRequestAuth } from './request'; import type { GraphQLResponse, @@ -10,8 +11,6 @@ import type { NotificationsExtensions, } from './types'; -export const MAX_PAGE_SIZE = 1000; - /** * Get the authenticated user * @@ -108,7 +107,7 @@ export function getNotificationsForUser( return apiRequestAuth(account, { query: print(QUERY), variables: { - first: MAX_PAGE_SIZE, + first: Constants.MAX_NOTIFICATIONS_PER_ACCOUNT, readState: settings.fetchOnlyUnreadNotifications ? 'unread' : null, // product: settings.product, }, diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 4c699f1..7adea76 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -10,6 +10,8 @@ export const Constants = { FETCH_NOTIFICATIONS_INTERVAL: 60000, REFRESH_ACCOUNTS_INTERVAL: 3600000, + MAX_NOTIFICATIONS_PER_ACCOUNT: 999, + DEFAULT_KEYBOARD_SHORTCUT: 'CommandOrControl+Shift+G', ATLASSIAN_URLS: { diff --git a/src/utils/notifications.ts b/src/utils/notifications.ts index fb669fd..0bda87c 100644 --- a/src/utils/notifications.ts +++ b/src/utils/notifications.ts @@ -6,11 +6,12 @@ import type { AtlasifyState, SettingsState, } from '../types'; -import { MAX_PAGE_SIZE, getNotificationsForUser } from './api/client'; +import { getNotificationsForUser } from './api/client'; import { determineFailureType } from './api/errors'; import type { AtlassianNotification, Category, ReadState } from './api/types'; import { getAccountUUID } from './auth/utils'; import { hideWindow, showWindow, updateTrayIcon } from './comms'; +import { Constants } from './constants'; import { READ_STATES } from './filters'; import { openNotification } from './links'; import { isWindows } from './platform'; @@ -30,7 +31,7 @@ export function getNotificationCount(notifications: AccountNotifications[]) { } export function hasMoreNotifications(notifications: AccountNotifications[]) { - return notifications.some((n) => n.hasNextPage); + return notifications?.some((n) => n.hasNextPage); } export const triggerNativeNotifications = ( @@ -153,7 +154,7 @@ export async function getAllNotifications( notifications: notifications, hasNextPage: res.extensions.notifications.response_info.responseSize === - MAX_PAGE_SIZE, // TODO - there is a bug in the Atlassian GraphQL response + Constants.MAX_NOTIFICATIONS_PER_ACCOUNT, // TODO - there is a bug in the Atlassian GraphQL response error: null, }; } catch (error) {