Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3396347
D8410.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8410.diff
View Options
diff --git a/lib/shared/reaction-utils.js b/lib/shared/reaction-utils.js
--- a/lib/shared/reaction-utils.js
+++ b/lib/shared/reaction-utils.js
@@ -33,20 +33,22 @@
return reactionText.join(' ');
}
-function getViewerAlreadySelectedMessageReactions(
+function useViewerAlreadySelectedMessageReactions(
reactions: ReactionInfo,
): $ReadOnlyArray<string> {
- const alreadySelectedEmojis = [];
+ return React.useMemo(() => {
+ const alreadySelectedEmojis = [];
- for (const reaction in reactions) {
- const reactionInfo = reactions[reaction];
+ for (const reaction in reactions) {
+ const reactionInfo = reactions[reaction];
- if (reactionInfo.viewerReacted) {
- alreadySelectedEmojis.push(reaction);
+ if (reactionInfo.viewerReacted) {
+ alreadySelectedEmojis.push(reaction);
+ }
}
- }
- return alreadySelectedEmojis;
+ return alreadySelectedEmojis;
+ }, [reactions]);
}
type MessageReactionListInfo = {
@@ -119,7 +121,7 @@
export {
stringForReactionList,
- getViewerAlreadySelectedMessageReactions,
+ useViewerAlreadySelectedMessageReactions,
useMessageReactionsList,
useCanCreateReactionFromMessage,
};
diff --git a/native/chat/multimedia-message-tooltip-button.react.js b/native/chat/multimedia-message-tooltip-button.react.js
--- a/native/chat/multimedia-message-tooltip-button.react.js
+++ b/native/chat/multimedia-message-tooltip-button.react.js
@@ -5,7 +5,7 @@
import { localIDPrefix } from 'lib/shared/message-utils.js';
import {
- getViewerAlreadySelectedMessageReactions,
+ useViewerAlreadySelectedMessageReactions,
useCanCreateReactionFromMessage,
} from 'lib/shared/reaction-utils.js';
@@ -155,10 +155,8 @@
[sendReaction, dismissTooltip],
);
- const alreadySelectedEmojis = React.useMemo(
- () => getViewerAlreadySelectedMessageReactions(item.reactions),
- [item.reactions],
- );
+ const alreadySelectedEmojis =
+ useViewerAlreadySelectedMessageReactions(reactions);
return (
<>
diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js
--- a/native/chat/robotext-message-tooltip-button.react.js
+++ b/native/chat/robotext-message-tooltip-button.react.js
@@ -5,7 +5,7 @@
import { localIDPrefix } from 'lib/shared/message-utils.js';
import {
- getViewerAlreadySelectedMessageReactions,
+ useViewerAlreadySelectedMessageReactions,
useCanCreateReactionFromMessage,
} from 'lib/shared/reaction-utils.js';
@@ -138,10 +138,8 @@
[sendReaction, dismissTooltip],
);
- const alreadySelectedEmojis = React.useMemo(
- () => getViewerAlreadySelectedMessageReactions(item.reactions),
- [item.reactions],
- );
+ const alreadySelectedEmojis =
+ useViewerAlreadySelectedMessageReactions(reactions);
return (
<>
diff --git a/native/chat/text-message-tooltip-button.react.js b/native/chat/text-message-tooltip-button.react.js
--- a/native/chat/text-message-tooltip-button.react.js
+++ b/native/chat/text-message-tooltip-button.react.js
@@ -5,7 +5,7 @@
import { localIDPrefix } from 'lib/shared/message-utils.js';
import {
- getViewerAlreadySelectedMessageReactions,
+ useViewerAlreadySelectedMessageReactions,
useCanCreateReactionFromMessage,
} from 'lib/shared/reaction-utils.js';
@@ -152,10 +152,8 @@
[sendReaction, dismissTooltip],
);
- const alreadySelectedEmojis = React.useMemo(
- () => getViewerAlreadySelectedMessageReactions(item.reactions),
- [item.reactions],
- );
+ const alreadySelectedEmojis =
+ useViewerAlreadySelectedMessageReactions(reactions);
return (
<MessageListContextProvider threadInfo={threadInfo}>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 11:54 AM (20 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2607497
Default Alt Text
D8410.diff (3 KB)
Attached To
Mode
D8410: [native] switch getViewerAlreadySelectedMessageReactions to useGetViewerAlreadySelectedMessageReactions
Attached
Detach File
Event Timeline
Log In to Comment