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/renderer/components/settings/SystemSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/context/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
82 changes: 12 additions & 70 deletions src/renderer/context/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
64 changes: 64 additions & 0 deletions src/renderer/context/defaults.ts
Original file line number Diff line number Diff line change
@@ -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,
};
2 changes: 1 addition & 1 deletion src/renderer/utils/comms.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/notifications/filters/filter.test.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/notifications/native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading