Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359183
D5853.id19900.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5853.id19900.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:43 AM (21 h, 57 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578639
Default Alt Text
D5853.id19900.diff (1 KB)
Attached To
Mode
D5853: [native] introduced useCanCreateReactionFromMessage function to reaction message utils
Attached
Detach File
Event Timeline
Log In to Comment