diff --git a/src/renderer/components/settings/SystemSettings.tsx b/src/renderer/components/settings/SystemSettings.tsx index ab69ff850..8d53a7025 100644 --- a/src/renderer/components/settings/SystemSettings.tsx +++ b/src/renderer/components/settings/SystemSettings.tsx @@ -12,7 +12,8 @@ import { import { APPLICATION } from '../../../shared/constants'; import { isLinux, isMacOS } from '../../../shared/platform'; -import { AppContext, defaultSettings } from '../../context/App'; +import { AppContext } from '../../context/App'; +import { defaultSettings } from '../../context/defaults'; import { OpenPreference } from '../../types'; import { Constants } from '../../utils/constants'; import { Checkbox } from '../fields/Checkbox'; diff --git a/src/renderer/context/App.test.tsx b/src/renderer/context/App.test.tsx index b9f09513f..bca9dd94b 100644 --- a/src/renderer/context/App.test.tsx +++ b/src/renderer/context/App.test.tsx @@ -10,7 +10,8 @@ import * as comms from '../utils/comms'; import { Constants } from '../utils/constants'; import * as notifications from '../utils/notifications/notifications'; import * as storage from '../utils/storage'; -import { AppContext, AppProvider, defaultSettings } from './App'; +import { AppContext, AppProvider } from './App'; +import { defaultSettings } from './defaults'; jest.mock('../hooks/useNotifications'); diff --git a/src/renderer/context/App.tsx b/src/renderer/context/App.tsx index 2f750c985..fe51084a6 100644 --- a/src/renderer/context/App.tsx +++ b/src/renderer/context/App.tsx @@ -14,23 +14,17 @@ import { useTheme } from '@primer/react'; import { namespacedEvent } from '../../shared/events'; import { useInterval } from '../hooks/useInterval'; import { useNotifications } from '../hooks/useNotifications'; -import { - type Account, - type AccountNotifications, - type AppearanceSettingsState, - type AuthState, - type FilterSettingsState, - type FilterValue, - type GitifyError, - GroupBy, - type NotificationSettingsState, - OpenPreference, - type SettingsState, - type SettingsValue, - type Status, - type SystemSettingsState, - Theme, - type Token, +import type { + Account, + AccountNotifications, + AuthState, + FilterSettingsState, + FilterValue, + GitifyError, + SettingsState, + SettingsValue, + Status, + Token, } from '../types'; import type { Notification } from '../typesGitHub'; import { headNotifications } from '../utils/api/client'; @@ -64,59 +58,7 @@ import { mapThemeModeToColorScheme, } from '../utils/theme'; import { zoomPercentageToLevel } from '../utils/zoom'; - -export const defaultAuth: AuthState = { - accounts: [], -}; - -const defaultAppearanceSettings: AppearanceSettingsState = { - theme: Theme.SYSTEM, - increaseContrast: false, - zoomPercentage: 100, - showAccountHeader: false, - wrapNotificationTitle: false, -}; - -const defaultNotificationSettings: NotificationSettingsState = { - groupBy: GroupBy.REPOSITORY, - fetchAllNotifications: true, - detailedNotifications: true, - showPills: true, - showNumber: true, - participating: false, - markAsDoneOnOpen: false, - markAsDoneOnUnsubscribe: false, - delayNotificationState: false, -}; - -const defaultSystemSettings: SystemSettingsState = { - openLinks: OpenPreference.FOREGROUND, - keyboardShortcut: true, - showNotificationsCountInTray: true, - showNotifications: true, - playSound: true, - notificationVolume: 20, - useAlternateIdleIcon: false, - openAtStartup: false, -}; - -export const defaultFilters: FilterSettingsState = { - filterUserTypes: [], - filterIncludeHandles: [], - filterExcludeHandles: [], - filterIncludeOrganizations: [], - filterExcludeOrganizations: [], - filterSubjectTypes: [], - filterStates: [], - filterReasons: [], -}; - -export const defaultSettings: SettingsState = { - ...defaultAppearanceSettings, - ...defaultNotificationSettings, - ...defaultSystemSettings, - ...defaultFilters, -}; +import { defaultAuth, defaultFilters, defaultSettings } from './defaults'; interface AppContextState { auth: AuthState; diff --git a/src/renderer/context/defaults.ts b/src/renderer/context/defaults.ts new file mode 100644 index 000000000..c65402a01 --- /dev/null +++ b/src/renderer/context/defaults.ts @@ -0,0 +1,64 @@ +import { + type AppearanceSettingsState, + type AuthState, + type FilterSettingsState, + GroupBy, + type NotificationSettingsState, + OpenPreference, + type SettingsState, + type SystemSettingsState, + Theme, +} from '../types'; + +export const defaultAuth: AuthState = { + accounts: [], +}; + +const defaultAppearanceSettings: AppearanceSettingsState = { + theme: Theme.SYSTEM, + increaseContrast: false, + zoomPercentage: 100, + showAccountHeader: false, + wrapNotificationTitle: false, +}; + +const defaultNotificationSettings: NotificationSettingsState = { + groupBy: GroupBy.REPOSITORY, + fetchAllNotifications: true, + detailedNotifications: true, + showPills: true, + showNumber: true, + participating: false, + markAsDoneOnOpen: false, + markAsDoneOnUnsubscribe: false, + delayNotificationState: false, +}; + +const defaultSystemSettings: SystemSettingsState = { + openLinks: OpenPreference.FOREGROUND, + keyboardShortcut: true, + showNotificationsCountInTray: true, + showNotifications: true, + playSound: true, + notificationVolume: 20, + useAlternateIdleIcon: false, + openAtStartup: false, +}; + +export const defaultFilters: FilterSettingsState = { + filterUserTypes: [], + filterIncludeHandles: [], + filterExcludeHandles: [], + filterIncludeOrganizations: [], + filterExcludeOrganizations: [], + filterSubjectTypes: [], + filterStates: [], + filterReasons: [], +}; + +export const defaultSettings: SettingsState = { + ...defaultAppearanceSettings, + ...defaultNotificationSettings, + ...defaultSystemSettings, + ...defaultFilters, +}; diff --git a/src/renderer/utils/comms.ts b/src/renderer/utils/comms.ts index 900e0fae3..6476727e1 100644 --- a/src/renderer/utils/comms.ts +++ b/src/renderer/utils/comms.ts @@ -1,7 +1,7 @@ import { ipcRenderer, shell } from 'electron'; import { namespacedEvent } from '../../shared/events'; -import { defaultSettings } from '../context/App'; +import { defaultSettings } from '../context/defaults'; import { type Link, OpenPreference } from '../types'; import { Constants } from './constants'; import { loadState } from './storage'; diff --git a/src/renderer/utils/notifications/filters/filter.test.ts b/src/renderer/utils/notifications/filters/filter.test.ts index d51a232e5..07bd76bfb 100644 --- a/src/renderer/utils/notifications/filters/filter.test.ts +++ b/src/renderer/utils/notifications/filters/filter.test.ts @@ -1,6 +1,6 @@ import { partialMockNotification } from '../../../__mocks__/partial-mocks'; import { mockSettings } from '../../../__mocks__/state-mocks'; -import { defaultSettings } from '../../../context/App'; +import { defaultSettings } from '../../../context/defaults'; import type { Link, SettingsState } from '../../../types'; import { filterBaseNotifications, diff --git a/src/renderer/utils/notifications/native.test.ts b/src/renderer/utils/notifications/native.test.ts index 3edebd3e7..e075452e1 100644 --- a/src/renderer/utils/notifications/native.test.ts +++ b/src/renderer/utils/notifications/native.test.ts @@ -3,7 +3,7 @@ import { mockSingleAccountNotifications, } from '../../__mocks__/notifications-mocks'; import { mockAuth } from '../../__mocks__/state-mocks'; -import { defaultSettings } from '../../context/App'; +import { defaultSettings } from '../../context/defaults'; import type { SettingsState } from '../../types'; import { mockGitHubNotifications } from '../api/__mocks__/response-mocks'; import * as comms from '../comms';