Page MenuHomePhabricator

D5853.diff
No OneTemporary

D5853.diff

diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js
--- a/native/chat/reaction-message-utils.js
+++ b/native/chat/reaction-message-utils.js
@@ -7,7 +7,15 @@
sendReactionMessage,
sendReactionMessageActionTypes,
} from 'lib/actions/message-actions';
+import { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils';
+import { threadHasPermission } from 'lib/shared/thread-utils';
+import type {
+ RobotextMessageInfo,
+ ComposableMessageInfo,
+} from 'lib/types/message-types';
+import { threadPermissions, type ThreadInfo } from 'lib/types/thread-types';
import type { BindServerCall, DispatchFunctions } from 'lib/utils/action-utils';
+import { useSelector } from 'lib/utils/redux-utils';
import type { TooltipRoute } from '../navigation/tooltip.react';
@@ -78,4 +86,30 @@
);
}
-export { onPressReact };
+function useCanCreateReactionFromMessage(
+ threadInfo: ThreadInfo,
+ targetMessageInfo: ComposableMessageInfo | RobotextMessageInfo,
+): boolean {
+ const targetMessageCreatorRelationship = useSelector(
+ state =>
+ state.userStore.userInfos[targetMessageInfo.creator.id]
+ ?.relationshipStatus,
+ );
+
+ if (!targetMessageInfo.id) {
+ return false;
+ }
+
+ const creatorRelationshipHasBlock =
+ targetMessageCreatorRelationship &&
+ relationshipBlockedInEitherDirection(targetMessageCreatorRelationship);
+
+ const hasPermission = threadHasPermission(
+ threadInfo,
+ threadPermissions.VOICED,
+ );
+
+ return hasPermission && !creatorRelationshipHasBlock;
+}
+
+export { onPressReact, useCanCreateReactionFromMessage };

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 6:04 AM (21 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578639
Default Alt Text
D5853.diff (1 KB)

Event Timeline