Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3172103
D4042.id12756.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4042.id12756.diff
View Options
diff --git a/web/modals/threads/notifications/notifications-modal.react.js b/web/modals/threads/notifications/notifications-modal.react.js
--- a/web/modals/threads/notifications/notifications-modal.react.js
+++ b/web/modals/threads/notifications/notifications-modal.react.js
@@ -46,6 +46,19 @@
setNotificationSettings,
] = React.useState<NotificationSettings>(initialThreadSetting);
+ const onFocusedSelected = React.useCallback(
+ () => setNotificationSettings('focused'),
+ [],
+ );
+ const onBadgeOnlySelected = React.useCallback(
+ () => setNotificationSettings('badge-only'),
+ [],
+ );
+ const onBackgroundSelected = React.useCallback(
+ () => setNotificationSettings('background'),
+ [],
+ );
+
const notificationIconStyle = React.useMemo(() => ({ width: 'auto' }), []);
const isFocusedSelected = notificationSettings === 'focused';
@@ -68,10 +81,10 @@
title="Focused (enabled)"
description={description}
icon={icon}
- onSelect={() => setNotificationSettings('focused')}
+ onSelect={onFocusedSelected}
/>
);
- }, [isFocusedSelected, notificationIconStyle]);
+ }, [isFocusedSelected, notificationIconStyle, onFocusedSelected]);
const isFocusedBadgeOnlySelected = notificationSettings === 'badge-only';
const focusedBadgeOnlyItem = React.useMemo(() => {
@@ -93,10 +106,10 @@
title="Focused (badge only)"
description={description}
icon={icon}
- onSelect={() => setNotificationSettings('badge-only')}
+ onSelect={onBadgeOnlySelected}
/>
);
- }, [isFocusedBadgeOnlySelected, notificationIconStyle]);
+ }, [isFocusedBadgeOnlySelected, notificationIconStyle, onBadgeOnlySelected]);
const isBackgroundSelected = notificationSettings === 'background';
const backgroundItem = React.useMemo(() => {
@@ -118,10 +131,10 @@
title="Background"
description={description}
icon={icon}
- onSelect={() => setNotificationSettings('background')}
+ onSelect={onBackgroundSelected}
/>
);
- }, [isBackgroundSelected, notificationIconStyle]);
+ }, [isBackgroundSelected, notificationIconStyle, onBackgroundSelected]);
const dispatchActionPromise = useDispatchActionPromise();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 2:23 PM (19 h, 38 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2442857
Default Alt Text
D4042.id12756.diff (2 KB)
Attached To
Mode
D4042: [web] Memoize `NotificationsOption` `onSelect` prop w/ `useCallback` hook
Attached
Detach File
Event Timeline
Log In to Comment