Page MenuHomePhabricator

D5853.id19907.diff
No OneTemporary

D5853.id19907.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, 7:41 AM (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578639
Default Alt Text
D5853.id19907.diff (1 KB)

Event Timeline