Skip to content

Commit 05e2da3

Browse files
committed
adjust styling, use default value
Signed-off-by: Adam Setch <[email protected]>
1 parent 04e79d1 commit 05e2da3

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/renderer/__mocks__/state-mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ const mockNotificationSettings: NotificationSettingsState = {
9393
markAsDoneOnOpen: false,
9494
markAsDoneOnUnsubscribe: false,
9595
delayNotificationState: false,
96-
notificationVolume: 20,
9796
};
9897

9998
const mockSystemSettings: SystemSettingsState = {
@@ -102,6 +101,7 @@ const mockSystemSettings: SystemSettingsState = {
102101
showNotificationsCountInTray: true,
103102
showNotifications: true,
104103
playSound: true,
104+
notificationVolume: 20,
105105
useAlternateIdleIcon: false,
106106
openAtStartup: false,
107107
};

src/renderer/components/settings/SystemSettings.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818

1919
import { APPLICATION } from '../../../shared/constants';
2020
import { isLinux, isMacOS } from '../../../shared/platform';
21-
import { AppContext } from '../../context/App';
21+
import { AppContext, defaultSettings } from '../../context/App';
2222
import { OpenPreference } from '../../types';
2323
import { Constants } from '../../utils/constants';
2424
import { Checkbox } from '../fields/Checkbox';
@@ -91,7 +91,7 @@ export const SystemSettings: FC = () => {
9191
onChange={(evt) => updateSetting('playSound', evt.target.checked)}
9292
/>
9393

94-
{settings.playSound && (
94+
<Box className="pl-6" hidden={!settings.playSound}>
9595
<Stack
9696
direction="horizontal"
9797
gap="condensed"
@@ -145,13 +145,16 @@ export const SystemSettings: FC = () => {
145145
icon={XCircleIcon}
146146
unsafeDisableTooltip={true}
147147
onClick={() => {
148-
updateSetting('notificationVolume', 20);
148+
updateSetting(
149+
'notificationVolume',
150+
defaultSettings.notificationVolume,
151+
);
149152
}}
150153
data-testid="settings-volume-reset"
151154
/>
152155
</ButtonGroup>
153156
</Stack>
154-
)}
157+
</Box>
155158

156159
<Checkbox
157160
name="useAlternateIdleIcon"

src/renderer/context/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ const defaultNotificationSettings: NotificationSettingsState = {
8585
markAsDoneOnOpen: false,
8686
markAsDoneOnUnsubscribe: false,
8787
delayNotificationState: false,
88-
notificationVolume: 20,
8988
};
9089

9190
const defaultSystemSettings: SystemSettingsState = {
@@ -94,6 +93,7 @@ const defaultSystemSettings: SystemSettingsState = {
9493
showNotificationsCountInTray: true,
9594
showNotifications: true,
9695
playSound: true,
96+
notificationVolume: 20,
9797
useAlternateIdleIcon: false,
9898
openAtStartup: false,
9999
};

src/renderer/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export interface NotificationSettingsState {
8181
markAsDoneOnOpen: boolean;
8282
markAsDoneOnUnsubscribe: boolean;
8383
delayNotificationState: boolean;
84-
notificationVolume: number;
8584
}
8685

8786
export interface SystemSettingsState {
@@ -91,6 +90,7 @@ export interface SystemSettingsState {
9190
showNotifications: boolean;
9291
useAlternateIdleIcon: boolean;
9392
playSound: boolean;
93+
notificationVolume: number;
9494
openAtStartup: boolean;
9595
}
9696

src/renderer/utils/notifications/native.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from 'node:path';
22

33
import { APPLICATION } from '../../../shared/constants';
44
import { isWindows } from '../../../shared/platform';
5+
import { defaultSettings } from '../../context/App';
56
import type { AccountNotifications, GitifyState } from '../../types';
67
import { Notification } from '../../typesGitHub';
78
import { getAccountUUID } from '../auth/utils';
@@ -86,7 +87,9 @@ export const raiseNativeNotification = (notifications: Notification[]) => {
8687
return nativeNotification;
8788
};
8889

89-
export const raiseSoundNotification = (volume = 0.2) => {
90+
export const raiseSoundNotification = (
91+
volume = defaultSettings.notificationVolume / 100,
92+
) => {
9093
const audio = new Audio(
9194
path.join(
9295
__dirname,

0 commit comments

Comments
 (0)