Skip to content

Commit 7598377

Browse files
authored
refactor: checkbox onChange fns (#2550)
* refactor: checkbox onChange fns Signed-off-by: Adam Setch <adam.setch@outlook.com> * refactor: checkbox onChange fns Signed-off-by: Adam Setch <adam.setch@outlook.com> --------- Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 24f48da commit 7598377

File tree

5 files changed

+62
-38
lines changed

5 files changed

+62
-38
lines changed

src/renderer/components/filters/FilterSection.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ export const FilterSection = <T extends FilterSettingsValue>({
8383
key={type as string}
8484
label={typeTitle}
8585
name={typeTitle}
86-
onChange={(evt) =>
87-
updateFilter(filterSetting, type, evt.target.checked)
88-
}
86+
onChange={() => updateFilter(filterSetting, type, !isChecked)}
8987
tooltip={
9088
typeDescription ? <Text>{typeDescription}</Text> : null
9189
}

src/renderer/components/settings/AppearanceSettings.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ export const AppearanceSettings: FC = () => {
8686
checked={settings.increaseContrast}
8787
label="Increase contrast"
8888
name="increaseContrast"
89-
onChange={(evt) =>
90-
updateSetting('increaseContrast', evt.target.checked)
89+
onChange={() =>
90+
updateSetting('increaseContrast', !settings.increaseContrast)
9191
}
9292
tooltip={
9393
<Text>
@@ -147,8 +147,8 @@ export const AppearanceSettings: FC = () => {
147147
checked={settings.showAccountHeader}
148148
label="Show account header"
149149
name="showAccountHeader"
150-
onChange={(evt) =>
151-
updateSetting('showAccountHeader', evt.target.checked)
150+
onChange={() =>
151+
updateSetting('showAccountHeader', !settings.showAccountHeader)
152152
}
153153
tooltip={
154154
<Text>
@@ -163,8 +163,11 @@ export const AppearanceSettings: FC = () => {
163163
checked={settings.wrapNotificationTitle}
164164
label="Show full notification title"
165165
name="wrapNotificationTitle"
166-
onChange={(evt) =>
167-
updateSetting('wrapNotificationTitle', evt.target.checked)
166+
onChange={() =>
167+
updateSetting(
168+
'wrapNotificationTitle',
169+
!settings.wrapNotificationTitle,
170+
)
168171
}
169172
tooltip={
170173
<Text>

src/renderer/components/settings/NotificationSettings.tsx

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ export const NotificationSettings: FC = () => {
179179
checked={settings.fetchAllNotifications}
180180
label="Fetch all notifications"
181181
name="fetchAllNotifications"
182-
onChange={(evt) =>
183-
updateSetting('fetchAllNotifications', evt.target.checked)
182+
onChange={() =>
183+
updateSetting(
184+
'fetchAllNotifications',
185+
!settings.fetchAllNotifications,
186+
)
184187
}
185188
tooltip={
186189
<Stack direction="vertical" gap="condensed">
@@ -201,8 +204,11 @@ export const NotificationSettings: FC = () => {
201204
checked={settings.detailedNotifications}
202205
label="Fetch detailed notifications"
203206
name="detailedNotifications"
204-
onChange={(evt) =>
205-
updateSetting('detailedNotifications', evt.target.checked)
207+
onChange={() =>
208+
updateSetting(
209+
'detailedNotifications',
210+
!settings.detailedNotifications,
211+
)
206212
}
207213
tooltip={
208214
<Stack direction="vertical" gap="condensed">
@@ -232,7 +238,7 @@ export const NotificationSettings: FC = () => {
232238
checked={settings.showPills}
233239
label="Show notification metric pills"
234240
name="showPills"
235-
onChange={(evt) => updateSetting('showPills', evt.target.checked)}
241+
onChange={() => updateSetting('showPills', !settings.showPills)}
236242
tooltip={
237243
<Stack direction="vertical" gap="condensed">
238244
<Text>Show notification metric pills for:</Text>
@@ -268,9 +274,7 @@ export const NotificationSettings: FC = () => {
268274
checked={settings.showNumber}
269275
label="Show GitHub number"
270276
name="showNumber"
271-
onChange={(evt) =>
272-
updateSetting('showNumber', evt.target.checked)
273-
}
277+
onChange={() => updateSetting('showNumber', !settings.showNumber)}
274278
tooltip={
275279
<Stack direction="vertical" gap="condensed">
276280
<Text>Show GitHub number for:</Text>
@@ -302,7 +306,9 @@ export const NotificationSettings: FC = () => {
302306
checked={settings.participating}
303307
label="Fetch only participating"
304308
name="showOnlyParticipating"
305-
onChange={(evt) => updateSetting('participating', evt.target.checked)}
309+
onChange={() =>
310+
updateSetting('participating', !settings.participating)
311+
}
306312
tooltip={
307313
<Stack direction="vertical" gap="condensed">
308314
<Text>
@@ -337,8 +343,11 @@ export const NotificationSettings: FC = () => {
337343
checked={settings.fetchReadNotifications}
338344
label="Fetch read & done notifications"
339345
name="fetchReadNotifications"
340-
onChange={(evt) =>
341-
updateSetting('fetchReadNotifications', evt.target.checked)
346+
onChange={() =>
347+
updateSetting(
348+
'fetchReadNotifications',
349+
!settings.fetchReadNotifications,
350+
)
342351
}
343352
tooltip={
344353
<Stack direction="vertical" gap="condensed">
@@ -360,8 +369,8 @@ export const NotificationSettings: FC = () => {
360369
checked={settings.markAsDoneOnOpen}
361370
label="Mark as done on open"
362371
name="markAsDoneOnOpen"
363-
onChange={(evt) =>
364-
updateSetting('markAsDoneOnOpen', evt.target.checked)
372+
onChange={() =>
373+
updateSetting('markAsDoneOnOpen', !settings.markAsDoneOnOpen)
365374
}
366375
tooltip={
367376
<Text>
@@ -375,8 +384,11 @@ export const NotificationSettings: FC = () => {
375384
checked={settings.markAsDoneOnUnsubscribe}
376385
label="Mark as done on unsubscribe"
377386
name="markAsDoneOnUnsubscribe"
378-
onChange={(evt) =>
379-
updateSetting('markAsDoneOnUnsubscribe', evt.target.checked)
387+
onChange={() =>
388+
updateSetting(
389+
'markAsDoneOnUnsubscribe',
390+
!settings.markAsDoneOnUnsubscribe,
391+
)
380392
}
381393
tooltip={
382394
<Text>
@@ -390,8 +402,11 @@ export const NotificationSettings: FC = () => {
390402
checked={settings.delayNotificationState}
391403
label="Delay notification state"
392404
name="delayNotificationState"
393-
onChange={(evt) =>
394-
updateSetting('delayNotificationState', evt.target.checked)
405+
onChange={() =>
406+
updateSetting(
407+
'delayNotificationState',
408+
!settings.delayNotificationState,
409+
)
395410
}
396411
tooltip={
397412
<Text>

src/renderer/components/settings/SystemSettings.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export const SystemSettings: FC = () => {
6363
checked={settings.keyboardShortcut}
6464
label="Enable keyboard shortcut"
6565
name="keyboardShortcut"
66-
onChange={(evt) =>
67-
updateSetting('keyboardShortcut', evt.target.checked)
66+
onChange={() =>
67+
updateSetting('keyboardShortcut', !settings.keyboardShortcut)
6868
}
6969
tooltip={
7070
<div>
@@ -81,8 +81,8 @@ export const SystemSettings: FC = () => {
8181
checked={settings.showNotifications}
8282
label="Show system notifications"
8383
name="showNotifications"
84-
onChange={(evt) =>
85-
updateSetting('showNotifications', evt.target.checked)
84+
onChange={() =>
85+
updateSetting('showNotifications', !settings.showNotifications)
8686
}
8787
tooltip={
8888
<Text>
@@ -102,7 +102,7 @@ export const SystemSettings: FC = () => {
102102
checked={settings.playSound}
103103
label="Play sound"
104104
name="playSound"
105-
onChange={(evt) => updateSetting('playSound', evt.target.checked)}
105+
onChange={() => updateSetting('playSound', !settings.playSound)}
106106
/>
107107

108108
<ButtonGroup
@@ -165,7 +165,9 @@ export const SystemSettings: FC = () => {
165165
checked={settings.openAtStartup}
166166
label="Open at startup"
167167
name="openAtStartup"
168-
onChange={(evt) => updateSetting('openAtStartup', evt.target.checked)}
168+
onChange={() =>
169+
updateSetting('openAtStartup', !settings.openAtStartup)
170+
}
169171
tooltip={
170172
<Text>Launch {APPLICATION.NAME} automatically at startup.</Text>
171173
}

src/renderer/components/settings/TraySettings.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ export const TraySettings: FC = () => {
2222
checked={settings.showNotificationsCountInTray}
2323
label="Show notification count"
2424
name="showNotificationsCountInTray"
25-
onChange={(evt) =>
26-
updateSetting('showNotificationsCountInTray', evt.target.checked)
25+
onChange={() =>
26+
updateSetting(
27+
'showNotificationsCountInTray',
28+
!settings.showNotificationsCountInTray,
29+
)
2730
}
2831
tooltip={
2932
<Text>
@@ -38,8 +41,8 @@ export const TraySettings: FC = () => {
3841
checked={settings.useUnreadActiveIcon}
3942
label="Highlight unread notifications"
4043
name="useUnreadActiveIcon"
41-
onChange={(evt) =>
42-
updateSetting('useUnreadActiveIcon', evt.target.checked)
44+
onChange={() =>
45+
updateSetting('useUnreadActiveIcon', !settings.useUnreadActiveIcon)
4346
}
4447
tooltip={
4548
<Stack direction="vertical" gap="condensed">
@@ -55,8 +58,11 @@ export const TraySettings: FC = () => {
5558
checked={settings.useAlternateIdleIcon}
5659
label="Use alternate idle icon"
5760
name="useAlternateIdleIcon"
58-
onChange={(evt) =>
59-
updateSetting('useAlternateIdleIcon', evt.target.checked)
61+
onChange={() =>
62+
updateSetting(
63+
'useAlternateIdleIcon',
64+
!settings.useAlternateIdleIcon,
65+
)
6066
}
6167
tooltip={
6268
<Stack direction="vertical" gap="condensed">

0 commit comments

Comments
 (0)