-
Notifications
You must be signed in to change notification settings - Fork 62
[Fix] Hoist IPC call out of notification setState updater #492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,13 +98,11 @@ export default function GeneralSection() { | |
|
|
||
| const handleNotificationToggle = useCallback( | ||
| (key: 'taskComplete' | 'approvalRequest' | 'gatewayDisconnect', value: boolean) => { | ||
| setNotifyState((prev) => { | ||
| const next = { ...prev, [key]: value }; | ||
| window.clawwork.updateSettings({ notifications: next }); | ||
| return next; | ||
| }); | ||
| const next = { ...notifyState, [key]: value }; | ||
| setNotifyState(next); | ||
| window.clawwork.updateSettings({ notifications: next }); | ||
| }, | ||
| [], | ||
| [notifyState], | ||
|
Comment on lines
+101
to
+105
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hoisting the IPC call out of the To maintain state consistency while keeping the side effect out of the updater, consider using a |
||
| ); | ||
|
|
||
| const notificationToggles = [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other setting handlers in this component (e.g.,
handleThemeToggleat line 38 orhandleDensityChangeat line 46), consider adding a success toast after the settings are updated, and handle potential IPC errors to inform the user if the persistence fails.