Page MenuHomePhabricator

D8410.diff
No OneTemporary

D8410.diff

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

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)

Event Timeline