@amityco/react-native-social-uikit 4.0.0 → 4.0.1-183811fd.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/core/assets/icons/index.js +8 -0
- package/lib/commonjs/core/assets/icons/index.js.map +1 -1
- package/lib/commonjs/core/assets/icons/visitorLimit.js +26 -0
- package/lib/commonjs/core/assets/icons/visitorLimit.js.map +1 -0
- package/lib/commonjs/core/constants/index.js +11 -1
- package/lib/commonjs/core/constants/index.js.map +1 -1
- package/lib/commonjs/core/hooks/useAuth.js +6 -2
- package/lib/commonjs/core/hooks/useAuth.js.map +1 -1
- package/lib/commonjs/core/providers/AmityUIKitProvider.js.map +1 -1
- package/lib/commonjs/core/providers/AuthProvider.js +40 -16
- package/lib/commonjs/core/providers/AuthProvider.js.map +1 -1
- package/lib/commonjs/core/routes/AmityUIKitNavigator.js +23 -1
- package/lib/commonjs/core/routes/AmityUIKitNavigator.js.map +1 -1
- package/lib/commonjs/social/components/Social/CommentList/CommentList.js +6 -1
- package/lib/commonjs/social/components/Social/CommentList/CommentList.js.map +1 -1
- package/lib/commonjs/social/components/Social/CommentListItem/CommentListItem.js +14 -3
- package/lib/commonjs/social/components/Social/CommentListItem/CommentListItem.js.map +1 -1
- package/lib/commonjs/social/components/legacy/Social/ReplyCommentList/index.js +10 -2
- package/lib/commonjs/social/components/legacy/Social/ReplyCommentList/index.js.map +1 -1
- package/lib/commonjs/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js +6 -1
- package/lib/commonjs/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js.map +1 -1
- package/lib/commonjs/social/features/comment/components/PostComment/CommentListItem/CommentListItem.js +13 -3
- package/lib/commonjs/social/features/comment/components/PostComment/CommentListItem/CommentListItem.js.map +1 -1
- package/lib/commonjs/social/features/comment/components/PostComment/ReplyCommentList/index.js +10 -2
- package/lib/commonjs/social/features/comment/components/PostComment/ReplyCommentList/index.js.map +1 -1
- package/lib/commonjs/social/features/feed/components/TopNavigation/TopNavigation.js +5 -1
- package/lib/commonjs/social/features/feed/components/TopNavigation/TopNavigation.js.map +1 -1
- package/lib/commonjs/social/features/post/Detail/index.js +6 -2
- package/lib/commonjs/social/features/post/Detail/index.js.map +1 -1
- package/lib/commonjs/social/features/post/components/Content/Content.js +5 -1
- package/lib/commonjs/social/features/post/components/Content/Content.js.map +1 -1
- package/lib/commonjs/social/features/post/components/EngagementActions/Components/DetailStyle.js +16 -10
- package/lib/commonjs/social/features/post/components/EngagementActions/Components/DetailStyle.js.map +1 -1
- package/lib/commonjs/social/features/post/components/EngagementActions/Components/FeedStyle.js +17 -9
- package/lib/commonjs/social/features/post/components/EngagementActions/Components/FeedStyle.js.map +1 -1
- package/lib/commonjs/social/features/user/Profile/components/Header/hooks/useHeader.js +6 -1
- package/lib/commonjs/social/features/user/Profile/components/Header/hooks/useHeader.js.map +1 -1
- package/lib/commonjs/social/features/visitor/UsageLimit/UsageLimit.js +46 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/UsageLimit.js.map +1 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/hooks/index.js +13 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/hooks/index.js.map +1 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/hooks/useUsageLimit.js +54 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/hooks/useUsageLimit.js.map +1 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/index.js +13 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/index.js.map +1 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/styles.js +52 -0
- package/lib/commonjs/social/features/visitor/UsageLimit/styles.js.map +1 -0
- package/lib/commonjs/social/hooks/index.js +22 -0
- package/lib/commonjs/social/hooks/index.js.map +1 -1
- package/lib/commonjs/social/hooks/useCommunityEngagementBehavior.js +57 -0
- package/lib/commonjs/social/hooks/useCommunityEngagementBehavior.js.map +1 -0
- package/lib/commonjs/social/hooks/useGlobalBehavior.js +44 -0
- package/lib/commonjs/social/hooks/useGlobalBehavior.js.map +1 -0
- package/lib/commonjs/social/hooks/usePostPermission.js +4 -2
- package/lib/commonjs/social/hooks/usePostPermission.js.map +1 -1
- package/lib/commonjs/social/hooks/useStoryPermission.js +3 -2
- package/lib/commonjs/social/hooks/useStoryPermission.js.map +1 -1
- package/lib/commonjs/social/providers/BehaviourProvider.js +1 -0
- package/lib/commonjs/social/providers/BehaviourProvider.js.map +1 -1
- package/lib/commonjs/social/screens/SocialHomePage/index.js +12 -5
- package/lib/commonjs/social/screens/SocialHomePage/index.js.map +1 -1
- package/lib/commonjs/social/screens/VisitorUsageLimit/VisitorUsageLimit.js +11 -0
- package/lib/commonjs/social/screens/VisitorUsageLimit/VisitorUsageLimit.js.map +1 -0
- package/lib/commonjs/social/screens/VisitorUsageLimit/index.js +13 -0
- package/lib/commonjs/social/screens/VisitorUsageLimit/index.js.map +1 -0
- package/lib/module/core/assets/icons/index.js +1 -0
- package/lib/module/core/assets/icons/index.js.map +1 -1
- package/lib/module/core/assets/icons/visitorLimit.js +19 -0
- package/lib/module/core/assets/icons/visitorLimit.js.map +1 -0
- package/lib/module/core/constants/index.js +10 -0
- package/lib/module/core/constants/index.js.map +1 -1
- package/lib/module/core/hooks/useAuth.js +6 -2
- package/lib/module/core/hooks/useAuth.js.map +1 -1
- package/lib/module/core/providers/AmityUIKitProvider.js.map +1 -1
- package/lib/module/core/providers/AuthProvider.js +40 -16
- package/lib/module/core/providers/AuthProvider.js.map +1 -1
- package/lib/module/core/routes/AmityUIKitNavigator.js +23 -1
- package/lib/module/core/routes/AmityUIKitNavigator.js.map +1 -1
- package/lib/module/social/components/Social/CommentList/CommentList.js +6 -1
- package/lib/module/social/components/Social/CommentList/CommentList.js.map +1 -1
- package/lib/module/social/components/Social/CommentListItem/CommentListItem.js +14 -3
- package/lib/module/social/components/Social/CommentListItem/CommentListItem.js.map +1 -1
- package/lib/module/social/components/legacy/Social/ReplyCommentList/index.js +10 -2
- package/lib/module/social/components/legacy/Social/ReplyCommentList/index.js.map +1 -1
- package/lib/module/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js +7 -2
- package/lib/module/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js.map +1 -1
- package/lib/module/social/features/comment/components/PostComment/CommentListItem/CommentListItem.js +14 -4
- package/lib/module/social/features/comment/components/PostComment/CommentListItem/CommentListItem.js.map +1 -1
- package/lib/module/social/features/comment/components/PostComment/ReplyCommentList/index.js +10 -2
- package/lib/module/social/features/comment/components/PostComment/ReplyCommentList/index.js.map +1 -1
- package/lib/module/social/features/feed/components/TopNavigation/TopNavigation.js +5 -1
- package/lib/module/social/features/feed/components/TopNavigation/TopNavigation.js.map +1 -1
- package/lib/module/social/features/post/Detail/index.js +6 -2
- package/lib/module/social/features/post/Detail/index.js.map +1 -1
- package/lib/module/social/features/post/components/Content/Content.js +5 -1
- package/lib/module/social/features/post/components/Content/Content.js.map +1 -1
- package/lib/module/social/features/post/components/EngagementActions/Components/DetailStyle.js +17 -11
- package/lib/module/social/features/post/components/EngagementActions/Components/DetailStyle.js.map +1 -1
- package/lib/module/social/features/post/components/EngagementActions/Components/FeedStyle.js +18 -10
- package/lib/module/social/features/post/components/EngagementActions/Components/FeedStyle.js.map +1 -1
- package/lib/module/social/features/user/Profile/components/Header/hooks/useHeader.js +7 -2
- package/lib/module/social/features/user/Profile/components/Header/hooks/useHeader.js.map +1 -1
- package/lib/module/social/features/visitor/UsageLimit/UsageLimit.js +40 -0
- package/lib/module/social/features/visitor/UsageLimit/UsageLimit.js.map +1 -0
- package/lib/module/social/features/visitor/UsageLimit/hooks/index.js +2 -0
- package/lib/module/social/features/visitor/UsageLimit/hooks/index.js.map +1 -0
- package/lib/module/social/features/visitor/UsageLimit/hooks/useUsageLimit.js +47 -0
- package/lib/module/social/features/visitor/UsageLimit/hooks/useUsageLimit.js.map +1 -0
- package/lib/module/social/features/visitor/UsageLimit/index.js +2 -0
- package/lib/module/social/features/visitor/UsageLimit/index.js.map +1 -0
- package/lib/module/social/features/visitor/UsageLimit/styles.js +45 -0
- package/lib/module/social/features/visitor/UsageLimit/styles.js.map +1 -0
- package/lib/module/social/hooks/index.js +2 -0
- package/lib/module/social/hooks/index.js.map +1 -1
- package/lib/module/social/hooks/useCommunityEngagementBehavior.js +50 -0
- package/lib/module/social/hooks/useCommunityEngagementBehavior.js.map +1 -0
- package/lib/module/social/hooks/useGlobalBehavior.js +36 -0
- package/lib/module/social/hooks/useGlobalBehavior.js.map +1 -0
- package/lib/module/social/hooks/usePostPermission.js +4 -2
- package/lib/module/social/hooks/usePostPermission.js.map +1 -1
- package/lib/module/social/hooks/useStoryPermission.js +3 -2
- package/lib/module/social/hooks/useStoryPermission.js.map +1 -1
- package/lib/module/social/providers/BehaviourProvider.js +1 -0
- package/lib/module/social/providers/BehaviourProvider.js.map +1 -1
- package/lib/module/social/screens/SocialHomePage/index.js +13 -6
- package/lib/module/social/screens/SocialHomePage/index.js.map +1 -1
- package/lib/module/social/screens/VisitorUsageLimit/VisitorUsageLimit.js +5 -0
- package/lib/module/social/screens/VisitorUsageLimit/VisitorUsageLimit.js.map +1 -0
- package/lib/module/social/screens/VisitorUsageLimit/index.js +2 -0
- package/lib/module/social/screens/VisitorUsageLimit/index.js.map +1 -0
- package/lib/typescript/core/assets/icons/index.d.ts +1 -0
- package/lib/typescript/core/assets/icons/index.d.ts.map +1 -1
- package/lib/typescript/core/assets/icons/visitorLimit.d.ts +3 -0
- package/lib/typescript/core/assets/icons/visitorLimit.d.ts.map +1 -0
- package/lib/typescript/core/constants/index.d.ts +10 -0
- package/lib/typescript/core/constants/index.d.ts.map +1 -1
- package/lib/typescript/core/hooks/useAuth.d.ts.map +1 -1
- package/lib/typescript/core/providers/AmityUIKitProvider.d.ts +2 -1
- package/lib/typescript/core/providers/AmityUIKitProvider.d.ts.map +1 -1
- package/lib/typescript/core/providers/AuthProvider.d.ts.map +1 -1
- package/lib/typescript/core/routes/AmityUIKitNavigator.d.ts.map +1 -1
- package/lib/typescript/core/types/auth.d.ts +2 -0
- package/lib/typescript/core/types/auth.d.ts.map +1 -1
- package/lib/typescript/core/types/behaviour.d.ts +6 -0
- package/lib/typescript/core/types/behaviour.d.ts.map +1 -1
- package/lib/typescript/social/components/Social/CommentList/CommentList.d.ts.map +1 -1
- package/lib/typescript/social/components/Social/CommentListItem/CommentListItem.d.ts.map +1 -1
- package/lib/typescript/social/components/legacy/Social/ReplyCommentList/index.d.ts.map +1 -1
- package/lib/typescript/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.d.ts.map +1 -1
- package/lib/typescript/social/features/comment/components/PostComment/CommentListItem/CommentListItem.d.ts.map +1 -1
- package/lib/typescript/social/features/comment/components/PostComment/ReplyCommentList/index.d.ts.map +1 -1
- package/lib/typescript/social/features/feed/components/TopNavigation/TopNavigation.d.ts.map +1 -1
- package/lib/typescript/social/features/post/Detail/index.d.ts.map +1 -1
- package/lib/typescript/social/features/post/components/Content/Content.d.ts.map +1 -1
- package/lib/typescript/social/features/post/components/EngagementActions/Components/DetailStyle.d.ts.map +1 -1
- package/lib/typescript/social/features/post/components/EngagementActions/Components/FeedStyle.d.ts.map +1 -1
- package/lib/typescript/social/features/user/Profile/components/Header/hooks/useHeader.d.ts.map +1 -1
- package/lib/typescript/social/features/visitor/UsageLimit/UsageLimit.d.ts +2 -0
- package/lib/typescript/social/features/visitor/UsageLimit/UsageLimit.d.ts.map +1 -0
- package/lib/typescript/social/features/visitor/UsageLimit/hooks/index.d.ts +2 -0
- package/lib/typescript/social/features/visitor/UsageLimit/hooks/index.d.ts.map +1 -0
- package/lib/typescript/social/features/visitor/UsageLimit/hooks/useUsageLimit.d.ts +40 -0
- package/lib/typescript/social/features/visitor/UsageLimit/hooks/useUsageLimit.d.ts.map +1 -0
- package/lib/typescript/social/features/visitor/UsageLimit/index.d.ts +2 -0
- package/lib/typescript/social/features/visitor/UsageLimit/index.d.ts.map +1 -0
- package/lib/typescript/social/features/visitor/UsageLimit/styles.d.ts +40 -0
- package/lib/typescript/social/features/visitor/UsageLimit/styles.d.ts.map +1 -0
- package/lib/typescript/social/hooks/index.d.ts +2 -0
- package/lib/typescript/social/hooks/index.d.ts.map +1 -1
- package/lib/typescript/social/hooks/useCommunityEngagementBehavior.d.ts +18 -0
- package/lib/typescript/social/hooks/useCommunityEngagementBehavior.d.ts.map +1 -0
- package/lib/typescript/social/hooks/useGlobalBehavior.d.ts +16 -0
- package/lib/typescript/social/hooks/useGlobalBehavior.d.ts.map +1 -0
- package/lib/typescript/social/hooks/usePostPermission.d.ts.map +1 -1
- package/lib/typescript/social/hooks/useStoryPermission.d.ts.map +1 -1
- package/lib/typescript/social/providers/BehaviourProvider.d.ts.map +1 -1
- package/lib/typescript/social/screens/SocialHomePage/index.d.ts.map +1 -1
- package/lib/typescript/social/screens/VisitorUsageLimit/VisitorUsageLimit.d.ts +2 -0
- package/lib/typescript/social/screens/VisitorUsageLimit/VisitorUsageLimit.d.ts.map +1 -0
- package/lib/typescript/social/screens/VisitorUsageLimit/index.d.ts +2 -0
- package/lib/typescript/social/screens/VisitorUsageLimit/index.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/core/assets/icons/index.ts +1 -0
- package/src/core/assets/icons/visitorLimit.tsx +19 -0
- package/src/core/constants/index.ts +15 -0
- package/src/core/hooks/useAuth.ts +4 -0
- package/src/core/providers/AmityUIKitProvider.tsx +2 -1
- package/src/core/providers/AuthProvider.tsx +35 -11
- package/src/core/routes/AmityUIKitNavigator.tsx +26 -1
- package/src/core/types/auth.ts +2 -0
- package/src/core/types/behaviour.ts +6 -0
- package/src/social/components/Social/CommentList/CommentList.tsx +4 -1
- package/src/social/components/Social/CommentListItem/CommentListItem.tsx +20 -12
- package/src/social/components/legacy/Social/ReplyCommentList/index.tsx +18 -11
- package/src/social/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.tsx +10 -2
- package/src/social/features/comment/components/PostComment/CommentListItem/CommentListItem.tsx +23 -16
- package/src/social/features/comment/components/PostComment/ReplyCommentList/index.tsx +17 -11
- package/src/social/features/feed/components/TopNavigation/TopNavigation.tsx +3 -1
- package/src/social/features/post/Detail/index.tsx +5 -2
- package/src/social/features/post/components/Content/Content.tsx +7 -4
- package/src/social/features/post/components/EngagementActions/Components/DetailStyle.tsx +19 -14
- package/src/social/features/post/components/EngagementActions/Components/FeedStyle.tsx +20 -12
- package/src/social/features/user/Profile/components/Header/hooks/useHeader.ts +5 -2
- package/src/social/features/visitor/UsageLimit/UsageLimit.tsx +43 -0
- package/src/social/features/visitor/UsageLimit/hooks/index.ts +1 -0
- package/src/social/features/visitor/UsageLimit/hooks/useUsageLimit.ts +46 -0
- package/src/social/features/visitor/UsageLimit/index.ts +1 -0
- package/src/social/features/visitor/UsageLimit/styles.ts +45 -0
- package/src/social/hooks/index.ts +2 -0
- package/src/social/hooks/useCommunityEngagementBehavior.ts +57 -0
- package/src/social/hooks/useGlobalBehavior.ts +33 -0
- package/src/social/hooks/usePostPermission.ts +3 -1
- package/src/social/hooks/useStoryPermission.ts +8 -6
- package/src/social/providers/BehaviourProvider.tsx +1 -0
- package/src/social/screens/SocialHomePage/index.tsx +24 -11
- package/src/social/screens/VisitorUsageLimit/VisitorUsageLimit.tsx +5 -0
- package/src/social/screens/VisitorUsageLimit/index.ts +1 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FC, memo } from 'react';
|
|
2
2
|
import { TouchableOpacityProps } from 'react-native';
|
|
3
3
|
import { ComponentID, ElementID, PageID } from '../../enums/enumUIKitID';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useAmityElement,
|
|
6
|
+
useGlobalBehavior,
|
|
7
|
+
useJoinCommunity,
|
|
8
|
+
} from '../../hooks';
|
|
5
9
|
import { Button, BUTTON_SIZE } from '../../components/Button/Button';
|
|
6
10
|
import { plus } from '../../../core/assets/icons';
|
|
7
11
|
import { useCustomRankingGlobalFeed } from '../../hooks/useCustomRankingGlobalFeed';
|
|
@@ -36,9 +40,13 @@ const CommunityJoinButton: FC<CommunityJoinButtonType> = ({
|
|
|
36
40
|
},
|
|
37
41
|
});
|
|
38
42
|
|
|
43
|
+
const { handleGlobalBehavior } = useGlobalBehavior();
|
|
44
|
+
|
|
39
45
|
const handleJoinCommunity = () => {
|
|
40
46
|
if (!communityId) return;
|
|
41
|
-
|
|
47
|
+
handleGlobalBehavior({
|
|
48
|
+
defaultBehavior: () => joinCommunity(communityId),
|
|
49
|
+
});
|
|
42
50
|
};
|
|
43
51
|
|
|
44
52
|
if (isExcluded) return null;
|
package/src/social/features/comment/components/PostComment/CommentListItem/CommentListItem.tsx
CHANGED
|
@@ -43,7 +43,7 @@ import { useTheme } from 'react-native-paper';
|
|
|
43
43
|
import type { MyMD3Theme } from '../../../../../../core/providers/AmityUIKitProvider';
|
|
44
44
|
import ReplyCommentList from '../ReplyCommentList/index';
|
|
45
45
|
import { CommentRepository } from '@amityco/ts-sdk-react-native';
|
|
46
|
-
import { useTimeDifference } from '../../../../../hooks';
|
|
46
|
+
import { useGlobalBehavior, useTimeDifference } from '../../../../../hooks';
|
|
47
47
|
import ModeratorBadgeElement from '../../../../../elements/ModeratorBadgeElement/ModeratorBadgeElement';
|
|
48
48
|
import { BrandBadge } from '../../../../../elements/BrandBadge';
|
|
49
49
|
import { ComponentID, PageID } from '../../../../../enums';
|
|
@@ -315,6 +315,14 @@ const CommentListItem = ({
|
|
|
315
315
|
onClickReply && onClickReply(user, commentId);
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
+
const { handleGlobalBehavior, isVisitorOrBot } = useGlobalBehavior();
|
|
319
|
+
|
|
320
|
+
const onPressLike = () =>
|
|
321
|
+
handleGlobalBehavior({ defaultBehavior: addReactionToComment });
|
|
322
|
+
|
|
323
|
+
const onPressReply = () =>
|
|
324
|
+
handleGlobalBehavior({ defaultBehavior: onHandleReply });
|
|
325
|
+
|
|
318
326
|
const onPressCommentReaction = () => {
|
|
319
327
|
onNavigate && onNavigate();
|
|
320
328
|
setIsReactionListVisible(true);
|
|
@@ -399,27 +407,26 @@ const CommentListItem = ({
|
|
|
399
407
|
)}
|
|
400
408
|
</View>
|
|
401
409
|
|
|
402
|
-
<TouchableOpacity
|
|
403
|
-
onPress={() => addReactionToComment()}
|
|
404
|
-
style={styles.likeBtn}
|
|
405
|
-
>
|
|
410
|
+
<TouchableOpacity onPress={onPressLike} style={styles.likeBtn}>
|
|
406
411
|
<Text style={isLike ? styles.likedText : styles.btnText}>
|
|
407
412
|
{!isLike ? 'Like' : 'Liked'}
|
|
408
413
|
</Text>
|
|
409
414
|
</TouchableOpacity>
|
|
410
|
-
<TouchableOpacity
|
|
411
|
-
onPress={onHandleReply}
|
|
412
|
-
style={styles.likeBtn}
|
|
413
|
-
>
|
|
415
|
+
<TouchableOpacity onPress={onPressReply} style={styles.likeBtn}>
|
|
414
416
|
<Text style={styles.btnText}>Reply</Text>
|
|
415
417
|
</TouchableOpacity>
|
|
416
|
-
|
|
417
|
-
<
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
418
|
+
{!isVisitorOrBot && (
|
|
419
|
+
<TouchableOpacity
|
|
420
|
+
onPress={openModal}
|
|
421
|
+
style={styles.threeDots}
|
|
422
|
+
>
|
|
423
|
+
<SvgXml
|
|
424
|
+
xml={threeDots(theme.colors.base)}
|
|
425
|
+
width="20"
|
|
426
|
+
height="16"
|
|
427
|
+
/>
|
|
428
|
+
</TouchableOpacity>
|
|
429
|
+
)}
|
|
423
430
|
</View>
|
|
424
431
|
|
|
425
432
|
{likeReaction > 0 && (
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
import { Pressable } from 'react-native';
|
|
28
28
|
import useAuth from '../../../../../../core/hooks/useAuth';
|
|
29
29
|
import { useTimeDifference } from '../../../../../hooks/useTimeDifference';
|
|
30
|
+
import { useGlobalBehavior } from '../../../../../hooks/useGlobalBehavior';
|
|
30
31
|
import {
|
|
31
32
|
isReportTarget,
|
|
32
33
|
reportTargetById,
|
|
@@ -144,6 +145,12 @@ const ReplyCommentList = ({
|
|
|
144
145
|
await addCommentReaction(commentId, 'like');
|
|
145
146
|
}
|
|
146
147
|
};
|
|
148
|
+
|
|
149
|
+
const { handleGlobalBehavior, isVisitorOrBot } = useGlobalBehavior();
|
|
150
|
+
|
|
151
|
+
const onPressLike = () =>
|
|
152
|
+
handleGlobalBehavior({ defaultBehavior: addReactionToComment });
|
|
153
|
+
|
|
147
154
|
const deleteReplyComment = () => {
|
|
148
155
|
Alert.alert('Delete reply', 'This reply will be permanently deleted.', [
|
|
149
156
|
{
|
|
@@ -292,21 +299,20 @@ const ReplyCommentList = ({
|
|
|
292
299
|
)}
|
|
293
300
|
</View>
|
|
294
301
|
|
|
295
|
-
<TouchableOpacity
|
|
296
|
-
onPress={() => addReactionToComment()}
|
|
297
|
-
style={styles.likeBtn}
|
|
298
|
-
>
|
|
302
|
+
<TouchableOpacity onPress={onPressLike} style={styles.likeBtn}>
|
|
299
303
|
<Text style={isLike ? styles.likedText : styles.btnText}>
|
|
300
304
|
{!isLike ? 'Like' : 'Liked'}
|
|
301
305
|
</Text>
|
|
302
306
|
</TouchableOpacity>
|
|
303
|
-
|
|
304
|
-
<
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
307
|
+
{!isVisitorOrBot && (
|
|
308
|
+
<TouchableOpacity onPress={openModal} style={styles.threeDots}>
|
|
309
|
+
<SvgXml
|
|
310
|
+
xml={threeDots(theme.colors.base)}
|
|
311
|
+
width="20"
|
|
312
|
+
height="16"
|
|
313
|
+
/>
|
|
314
|
+
</TouchableOpacity>
|
|
315
|
+
)}
|
|
310
316
|
</View>
|
|
311
317
|
|
|
312
318
|
{likeReaction > 0 && (
|
|
@@ -15,6 +15,7 @@ import AmityCreatePostMenuComponent from '../CreatePostMenu';
|
|
|
15
15
|
import TextKeyElement from '../../../../elements/TextKeyElement/TextKeyElement';
|
|
16
16
|
import { usePopup } from '../../../../hooks/usePopup';
|
|
17
17
|
import Popup from '../../../../components/PopupMenu/PopupMenu';
|
|
18
|
+
import useAuth from '../../../../../core/hooks/useAuth';
|
|
18
19
|
|
|
19
20
|
type AmitySocialHomeTopNavigationComponentType = {
|
|
20
21
|
activeTab: string;
|
|
@@ -29,6 +30,7 @@ const AmitySocialHomeTopNavigationComponent: FC<
|
|
|
29
30
|
const theme = componentConfig.themeStyles;
|
|
30
31
|
const { AmitySocialHomeTopNavigationComponentBehaviour } = useBehaviour();
|
|
31
32
|
const { isOpen, setIsOpen, toggle } = usePopup();
|
|
33
|
+
const { isVisitorOrBot } = useAuth();
|
|
32
34
|
|
|
33
35
|
const [myCommunitiesTab] = useUiKitConfig({
|
|
34
36
|
page: PageID.social_home_page,
|
|
@@ -169,7 +171,7 @@ const AmitySocialHomeTopNavigationComponent: FC<
|
|
|
169
171
|
>
|
|
170
172
|
<Image source={searchIcon} style={styles.icon} />
|
|
171
173
|
</TouchableOpacity>
|
|
172
|
-
{activeTab !== exploreTab && (
|
|
174
|
+
{!isVisitorOrBot && activeTab !== exploreTab && (
|
|
173
175
|
<TouchableOpacity
|
|
174
176
|
style={styles.iconBtn}
|
|
175
177
|
onPress={onPressCreate}
|
|
@@ -43,6 +43,7 @@ import NetInfo from '@react-native-community/netinfo';
|
|
|
43
43
|
import { useToast } from '../../../../core/stores/slices/toastSlice';
|
|
44
44
|
import MyAvatar from '../../../components/MyAvatar/MyAvatar';
|
|
45
45
|
import { MAX_MENTION_USERS } from '../../../../core/constants';
|
|
46
|
+
import useAuth from '../../../../core/hooks/useAuth';
|
|
46
47
|
|
|
47
48
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
48
49
|
import ErrorComponent from '../../../components/ErrorComponent/ErrorComponent';
|
|
@@ -73,6 +74,8 @@ const AmityPostDetailPage: FC<AmityPostDetailPageType> = ({
|
|
|
73
74
|
}) => {
|
|
74
75
|
const pageId = PageID.post_detail_page;
|
|
75
76
|
const componentId = ComponentID.WildCardComponent;
|
|
77
|
+
|
|
78
|
+
const { isVisitorOrBot } = useAuth();
|
|
76
79
|
const disabledInteraction = false;
|
|
77
80
|
const navigation =
|
|
78
81
|
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
@@ -285,7 +288,7 @@ const AmityPostDetailPage: FC<AmityPostDetailPageType> = ({
|
|
|
285
288
|
</TouchableOpacity>
|
|
286
289
|
</View>
|
|
287
290
|
)}
|
|
288
|
-
{!disabledInteraction && (
|
|
291
|
+
{!disabledInteraction && !isVisitorOrBot && (
|
|
289
292
|
<View style={styles.InputWrap}>
|
|
290
293
|
<MyAvatar style={styles.myAvatar} />
|
|
291
294
|
<View style={styles.inputContainer}>
|
|
@@ -398,7 +401,7 @@ const AmityPostDetailPage: FC<AmityPostDetailPageType> = ({
|
|
|
398
401
|
postData?.targetType === 'community' && postData?.targetId
|
|
399
402
|
}
|
|
400
403
|
postType="post"
|
|
401
|
-
disabledInteraction={
|
|
404
|
+
disabledInteraction={disabledInteraction}
|
|
402
405
|
ListHeaderComponent={
|
|
403
406
|
postData && (
|
|
404
407
|
<AmityPostContentComponent
|
|
@@ -35,6 +35,7 @@ import { PostMenu } from '../../../../components/PostMenu';
|
|
|
35
35
|
import PinBadge from '../../../../elements/PinBadge';
|
|
36
36
|
import AnnouncementBadge from '../../../../elements/AnnouncementBadge';
|
|
37
37
|
import { Typography } from '../../../../../core/components/Typography/Typography';
|
|
38
|
+
import useAuth from '../../../../../core/hooks/useAuth';
|
|
38
39
|
|
|
39
40
|
type AmityPostContentComponentProps = {
|
|
40
41
|
post: Amity.Post;
|
|
@@ -74,6 +75,7 @@ const AmityPostContentComponent: FC<AmityPostContentComponentProps> = ({
|
|
|
74
75
|
componentId: componentId,
|
|
75
76
|
});
|
|
76
77
|
const styles = useStyles(themeStyles);
|
|
78
|
+
const { isVisitorOrBot } = useAuth();
|
|
77
79
|
const [textPost, setTextPost] = useState<string>('');
|
|
78
80
|
const [communityData, setCommunityData] = useState<Amity.Community>(null);
|
|
79
81
|
const navigation =
|
|
@@ -292,10 +294,11 @@ const AmityPostContentComponent: FC<AmityPostContentComponentProps> = ({
|
|
|
292
294
|
category === AmityPostCategory.PIN_AND_ANNOUNCEMENT) && (
|
|
293
295
|
<PinBadge componentId={ComponentID.post_content} />
|
|
294
296
|
)}
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
{!isVisitorOrBot &&
|
|
298
|
+
AmityPostContentComponentStyle ===
|
|
299
|
+
AmityPostContentComponentStyleEnum.feed && (
|
|
300
|
+
<PostMenu post={post} pageId={pageId} componentId={componentId} />
|
|
301
|
+
)}
|
|
299
302
|
</Pressable>
|
|
300
303
|
<View>
|
|
301
304
|
<View style={styles.bodySection}>
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from '@amityco/ts-sdk-react-native';
|
|
9
9
|
import { AmityPostEngagementActionsSubComponentType } from './type';
|
|
10
10
|
import { useStyles } from './styles';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useAmityComponent,
|
|
13
|
+
useCommunityEngagementBehavior,
|
|
14
|
+
} from '../../../../../hooks';
|
|
12
15
|
import { PageID, ComponentID } from '../../../../../enums';
|
|
13
16
|
import { SvgXml } from 'react-native-svg';
|
|
14
17
|
import { likeReaction } from '../../../../../../core/assets/icons/xml';
|
|
@@ -34,6 +37,7 @@ const DetailStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
34
37
|
componentId: ComponentID.post_content,
|
|
35
38
|
});
|
|
36
39
|
const styles = useStyles(themeStyles);
|
|
40
|
+
const { handleCommunityEngagement } = useCommunityEngagementBehavior();
|
|
37
41
|
const [postData, setPostData] = useState<Amity.Post>(null);
|
|
38
42
|
|
|
39
43
|
const { shareLink, handleSharePress } = usePostShareAction({
|
|
@@ -95,19 +99,20 @@ const DetailStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
95
99
|
}
|
|
96
100
|
}, [isLike, postId]);
|
|
97
101
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
const onPressReaction = useCallback(() => {
|
|
103
|
+
handleCommunityEngagement({
|
|
104
|
+
defaultBehavior: addReactionToPost,
|
|
105
|
+
isJoined: community ? community.isJoined : true,
|
|
106
|
+
});
|
|
107
|
+
}, [addReactionToPost, handleCommunityEngagement, community]);
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
);
|
|
110
|
-
}
|
|
109
|
+
const onClickReactions = useCallback(() => {
|
|
110
|
+
handleCommunityEngagement({
|
|
111
|
+
defaultBehavior: () => setIsReactionListVisible(true),
|
|
112
|
+
allowNonMember: true,
|
|
113
|
+
isJoined: community?.isJoined,
|
|
114
|
+
});
|
|
115
|
+
}, [handleCommunityEngagement, community]);
|
|
111
116
|
|
|
112
117
|
return (
|
|
113
118
|
<>
|
|
@@ -136,7 +141,7 @@ const DetailStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
136
141
|
</View>
|
|
137
142
|
<View style={[styles.actionSection, styles.detailActionSection]}>
|
|
138
143
|
<View style={styles.row}>
|
|
139
|
-
<TouchableOpacity onPress={
|
|
144
|
+
<TouchableOpacity onPress={onPressReaction} style={styles.likeBtn}>
|
|
140
145
|
{isLike ? (
|
|
141
146
|
<SvgXml
|
|
142
147
|
xml={likeReaction(themeStyles.colors.background)}
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
subscribeTopic,
|
|
9
9
|
} from '@amityco/ts-sdk-react-native';
|
|
10
10
|
import { useStyles } from './styles';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
useAmityComponent,
|
|
13
|
+
useCommunityEngagementBehavior,
|
|
14
|
+
} from '../../../../../hooks';
|
|
12
15
|
import { PageID, ComponentID } from '../../../../../enums';
|
|
13
16
|
import { SvgXml } from 'react-native-svg';
|
|
14
17
|
import { likeReaction } from '../../../../../../core/assets/icons/xml';
|
|
@@ -38,6 +41,7 @@ const FeedStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
38
41
|
});
|
|
39
42
|
const styles = useStyles(themeStyles);
|
|
40
43
|
const { AmityGlobalFeedComponentBehavior } = useBehaviour();
|
|
44
|
+
const { handleCommunityEngagement } = useCommunityEngagementBehavior();
|
|
41
45
|
const navigation =
|
|
42
46
|
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
|
|
43
47
|
const [postData, setPostData] = useState<Amity.Post>(null);
|
|
@@ -81,7 +85,14 @@ const FeedStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
81
85
|
}
|
|
82
86
|
}, [isLike, postData, postId]);
|
|
83
87
|
|
|
84
|
-
const
|
|
88
|
+
const onPressReaction = useCallback(() => {
|
|
89
|
+
handleCommunityEngagement({
|
|
90
|
+
defaultBehavior: addReactionToPost,
|
|
91
|
+
isJoined: community ? community.isJoined : true,
|
|
92
|
+
});
|
|
93
|
+
}, [addReactionToPost, handleCommunityEngagement, community]);
|
|
94
|
+
|
|
95
|
+
const goToPostDetail = useCallback(() => {
|
|
85
96
|
if (AmityGlobalFeedComponentBehavior.goToPostDetailPage) {
|
|
86
97
|
return AmityGlobalFeedComponentBehavior.goToPostDetailPage();
|
|
87
98
|
}
|
|
@@ -90,20 +101,17 @@ const FeedStyle: FC<AmityPostEngagementActionsSubComponentType> = ({
|
|
|
90
101
|
});
|
|
91
102
|
}, [AmityGlobalFeedComponentBehavior, navigation, postId]);
|
|
92
103
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</View>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
104
|
+
const onPressComment = useCallback(() => {
|
|
105
|
+
handleCommunityEngagement({
|
|
106
|
+
defaultBehavior: goToPostDetail,
|
|
107
|
+
isJoined: community ? community.isJoined : true,
|
|
108
|
+
});
|
|
109
|
+
}, [goToPostDetail, handleCommunityEngagement, community]);
|
|
102
110
|
|
|
103
111
|
return (
|
|
104
112
|
<Pressable onPress={onPressComment} style={styles.actionSection}>
|
|
105
113
|
<View style={styles.row}>
|
|
106
|
-
<TouchableOpacity onPress={
|
|
114
|
+
<TouchableOpacity onPress={onPressReaction} style={styles.likeBtn}>
|
|
107
115
|
{isLike ? (
|
|
108
116
|
<SvgXml
|
|
109
117
|
xml={likeReaction(themeStyles.colors.background)}
|
|
@@ -8,7 +8,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
|
8
8
|
import { RootStackParamList } from '../../../../../../../core/routes/RouteParamList';
|
|
9
9
|
import { UserRelationshipTab } from '../../../../../../types';
|
|
10
10
|
import { useBehaviour } from '../../../../../../providers/BehaviourProvider';
|
|
11
|
-
import { useBlockUser } from '../../../../../../hooks';
|
|
11
|
+
import { useBlockUser, useGlobalBehavior } from '../../../../../../hooks';
|
|
12
12
|
import useAuth from '../../../../../../../core/hooks/useAuth';
|
|
13
13
|
import { useFollowUser } from '../../../../../../hooks/queries/useFollowUser';
|
|
14
14
|
import useSocialSettings from '../../../../../../../core/hooks/useSocialSettings';
|
|
@@ -31,6 +31,7 @@ export function useHeader(user?: Amity.User) {
|
|
|
31
31
|
const { openBottomSheet, closeBottomSheet, bottomSheetHeight } =
|
|
32
32
|
useBottomSheet();
|
|
33
33
|
const { showToast } = useToast();
|
|
34
|
+
const { handleGlobalBehavior } = useGlobalBehavior();
|
|
34
35
|
const {
|
|
35
36
|
followUser,
|
|
36
37
|
unfollowUser,
|
|
@@ -56,7 +57,9 @@ export function useHeader(user?: Amity.User) {
|
|
|
56
57
|
|
|
57
58
|
const handleFollow = () => {
|
|
58
59
|
if (!user?.userId) return;
|
|
59
|
-
|
|
60
|
+
handleGlobalBehavior({
|
|
61
|
+
defaultBehavior: () => followUser(user.userId),
|
|
62
|
+
});
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
const handleUnfollow = () => {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
2
|
+
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
3
|
+
import { SvgXml } from 'react-native-svg';
|
|
4
|
+
import { Typography } from '../../../../core/components/Typography/Typography';
|
|
5
|
+
import { visitorLimit } from '../../../../core/assets/icons';
|
|
6
|
+
import { VISITOR_USAGE_LIMIT_MESSAGE } from '../../../../core/constants';
|
|
7
|
+
import { useUsageLimit } from './hooks';
|
|
8
|
+
|
|
9
|
+
export function UsageLimit() {
|
|
10
|
+
const { styles, theme, onPressSignIn } = useUsageLimit();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<SafeAreaView style={styles.container} edges={['top', 'left']}>
|
|
14
|
+
<View style={styles.contentContainer}>
|
|
15
|
+
<SvgXml
|
|
16
|
+
accessible
|
|
17
|
+
accessibilityLabel="Usage limit reached"
|
|
18
|
+
width={60}
|
|
19
|
+
height={40}
|
|
20
|
+
style={styles.icon}
|
|
21
|
+
xml={visitorLimit()}
|
|
22
|
+
color={theme.colors.secondaryShade4}
|
|
23
|
+
/>
|
|
24
|
+
<Typography.TitleBold style={styles.title}>
|
|
25
|
+
{VISITOR_USAGE_LIMIT_MESSAGE.TITLE}
|
|
26
|
+
</Typography.TitleBold>
|
|
27
|
+
<Typography.Caption style={styles.subtitle}>
|
|
28
|
+
{VISITOR_USAGE_LIMIT_MESSAGE.SUBTITLE}
|
|
29
|
+
</Typography.Caption>
|
|
30
|
+
<TouchableOpacity
|
|
31
|
+
style={styles.signInButton}
|
|
32
|
+
onPress={onPressSignIn}
|
|
33
|
+
accessibilityRole="button"
|
|
34
|
+
accessibilityLabel={VISITOR_USAGE_LIMIT_MESSAGE.SIGN_IN}
|
|
35
|
+
>
|
|
36
|
+
<Typography.BodyBold style={styles.signInText}>
|
|
37
|
+
{VISITOR_USAGE_LIMIT_MESSAGE.SIGN_IN}
|
|
38
|
+
</Typography.BodyBold>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</View>
|
|
41
|
+
</SafeAreaView>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useUsageLimit } from './useUsageLimit';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useCallback, useEffect } from 'react';
|
|
2
|
+
import { BackHandler } from 'react-native';
|
|
3
|
+
import { useStyles } from '../styles';
|
|
4
|
+
import { useToast } from '../../../../../core/stores/slices/toastSlice';
|
|
5
|
+
import { useBehaviour } from '../../../../providers/BehaviourProvider';
|
|
6
|
+
import {
|
|
7
|
+
VISITOR_USAGE_LIMIT_MESSAGE,
|
|
8
|
+
VISITOR_TOAST_DURATION,
|
|
9
|
+
} from '../../../../../core/constants';
|
|
10
|
+
|
|
11
|
+
export const useUsageLimit = () => {
|
|
12
|
+
const { styles, theme } = useStyles();
|
|
13
|
+
const { showToast } = useToast();
|
|
14
|
+
const { AmityGlobalBehaviour } = useBehaviour();
|
|
15
|
+
|
|
16
|
+
const showSignInToast = useCallback(() => {
|
|
17
|
+
showToast({
|
|
18
|
+
message: VISITOR_USAGE_LIMIT_MESSAGE.TOAST,
|
|
19
|
+
type: 'informative',
|
|
20
|
+
duration: VISITOR_TOAST_DURATION,
|
|
21
|
+
});
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
showSignInToast();
|
|
26
|
+
}, [showSignInToast]);
|
|
27
|
+
|
|
28
|
+
// Dead-end page: swallow the Android hardware back press so the user
|
|
29
|
+
// cannot navigate away from the error state.
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const subscription = BackHandler.addEventListener(
|
|
32
|
+
'hardwareBackPress',
|
|
33
|
+
() => true
|
|
34
|
+
);
|
|
35
|
+
return () => subscription.remove();
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const onPressSignIn = useCallback(() => {
|
|
39
|
+
if (AmityGlobalBehaviour?.handleVisitorUsageLimitSignIn) {
|
|
40
|
+
return AmityGlobalBehaviour.handleVisitorUsageLimitSignIn();
|
|
41
|
+
}
|
|
42
|
+
showSignInToast();
|
|
43
|
+
}, [AmityGlobalBehaviour, showSignInToast]);
|
|
44
|
+
|
|
45
|
+
return { styles, theme, onPressSignIn };
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UsageLimit } from './UsageLimit';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useTheme } from 'react-native-paper';
|
|
3
|
+
import type { MyMD3Theme } from '../../../../core/providers/AmityUIKitProvider';
|
|
4
|
+
|
|
5
|
+
export const useStyles = () => {
|
|
6
|
+
const theme = useTheme<MyMD3Theme>();
|
|
7
|
+
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
container: {
|
|
10
|
+
flex: 1,
|
|
11
|
+
backgroundColor: theme.colors.background,
|
|
12
|
+
},
|
|
13
|
+
contentContainer: {
|
|
14
|
+
flex: 1,
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
paddingHorizontal: 32,
|
|
17
|
+
flexDirection: 'column',
|
|
18
|
+
justifyContent: 'center',
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
marginBottom: 16,
|
|
22
|
+
},
|
|
23
|
+
title: {
|
|
24
|
+
maxWidth: 252,
|
|
25
|
+
textAlign: 'center',
|
|
26
|
+
color: theme.colors.baseShade3,
|
|
27
|
+
},
|
|
28
|
+
subtitle: {
|
|
29
|
+
maxWidth: 252,
|
|
30
|
+
textAlign: 'center',
|
|
31
|
+
color: theme.colors.baseShade3,
|
|
32
|
+
},
|
|
33
|
+
signInButton: {
|
|
34
|
+
marginTop: 16,
|
|
35
|
+
borderRadius: 8,
|
|
36
|
+
paddingVertical: 10,
|
|
37
|
+
paddingHorizontal: 16,
|
|
38
|
+
},
|
|
39
|
+
signInText: {
|
|
40
|
+
color: theme.colors.primary,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return { styles, theme };
|
|
45
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useBehaviour } from '../providers/BehaviourProvider';
|
|
3
|
+
import { useToast } from '../../core/stores/slices/toastSlice';
|
|
4
|
+
import { useGlobalBehavior } from './useGlobalBehavior';
|
|
5
|
+
import {
|
|
6
|
+
NON_MEMBER_ACTION_TOAST,
|
|
7
|
+
VISITOR_TOAST_DURATION,
|
|
8
|
+
} from '../../core/constants';
|
|
9
|
+
|
|
10
|
+
type HandleCommunityEngagementParams = {
|
|
11
|
+
defaultBehavior?: () => void;
|
|
12
|
+
// Actions a non-member is still allowed to perform (e.g. viewing the
|
|
13
|
+
// reaction list). When true the membership gate is skipped — only the
|
|
14
|
+
// visitor gate applies.
|
|
15
|
+
allowNonMember?: boolean;
|
|
16
|
+
isJoined?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Engagement gate for community posts, mirroring the Web UIKit's
|
|
21
|
+
* useCommunityProfileGlobalBehavior. Layers two checks on top of an action:
|
|
22
|
+
* - visitor/bot -> visitor toast / handleVisitorUserAction (via useGlobalBehavior)
|
|
23
|
+
* - signed-in non-member (community && !isJoined) -> join toast / handleNonMemberAction
|
|
24
|
+
* - member / allowNonMember / non-community post -> run the action
|
|
25
|
+
*/
|
|
26
|
+
export const useCommunityEngagementBehavior = () => {
|
|
27
|
+
const { showToast } = useToast();
|
|
28
|
+
const { AmityGlobalBehaviour } = useBehaviour();
|
|
29
|
+
const { handleGlobalBehavior, isVisitorOrBot } = useGlobalBehavior();
|
|
30
|
+
|
|
31
|
+
const handleCommunityEngagement = useCallback(
|
|
32
|
+
({
|
|
33
|
+
defaultBehavior,
|
|
34
|
+
allowNonMember,
|
|
35
|
+
isJoined,
|
|
36
|
+
}: HandleCommunityEngagementParams) => {
|
|
37
|
+
handleGlobalBehavior({
|
|
38
|
+
defaultBehavior: () => {
|
|
39
|
+
if (allowNonMember || isJoined) {
|
|
40
|
+
return defaultBehavior?.();
|
|
41
|
+
}
|
|
42
|
+
if (AmityGlobalBehaviour?.handleNonMemberAction) {
|
|
43
|
+
return AmityGlobalBehaviour.handleNonMemberAction();
|
|
44
|
+
}
|
|
45
|
+
return showToast({
|
|
46
|
+
message: NON_MEMBER_ACTION_TOAST,
|
|
47
|
+
type: 'informative',
|
|
48
|
+
duration: VISITOR_TOAST_DURATION,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
[handleGlobalBehavior, AmityGlobalBehaviour, showToast]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return { handleCommunityEngagement, isVisitorOrBot };
|
|
57
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import useAuth from '../../core/hooks/useAuth';
|
|
3
|
+
import { useBehaviour } from '../providers/BehaviourProvider';
|
|
4
|
+
import { useToast } from '../../core/stores/slices/toastSlice';
|
|
5
|
+
import {
|
|
6
|
+
VISITOR_USER_ACTION_TOAST,
|
|
7
|
+
VISITOR_TOAST_DURATION,
|
|
8
|
+
} from '../../core/constants';
|
|
9
|
+
|
|
10
|
+
export const useGlobalBehavior = () => {
|
|
11
|
+
const { showToast } = useToast();
|
|
12
|
+
const { isVisitorOrBot } = useAuth();
|
|
13
|
+
const { AmityGlobalBehaviour } = useBehaviour();
|
|
14
|
+
|
|
15
|
+
const handleGlobalBehavior = useCallback(
|
|
16
|
+
({ defaultBehavior }: { defaultBehavior?: () => void }) => {
|
|
17
|
+
if (isVisitorOrBot) {
|
|
18
|
+
if (AmityGlobalBehaviour?.handleVisitorUserAction) {
|
|
19
|
+
return AmityGlobalBehaviour.handleVisitorUserAction();
|
|
20
|
+
}
|
|
21
|
+
return showToast({
|
|
22
|
+
message: VISITOR_USER_ACTION_TOAST,
|
|
23
|
+
type: 'informative',
|
|
24
|
+
duration: VISITOR_TOAST_DURATION,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return defaultBehavior?.();
|
|
28
|
+
},
|
|
29
|
+
[isVisitorOrBot, AmityGlobalBehaviour, showToast]
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return { handleGlobalBehavior, isVisitorOrBot };
|
|
33
|
+
};
|
|
@@ -12,13 +12,14 @@ type UsePostPermissionParams = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export function usePostPermission({ community }: UsePostPermissionParams) {
|
|
15
|
-
const { client } = useAuth();
|
|
15
|
+
const { client, isVisitorOrBot } = useAuth();
|
|
16
16
|
const [hasPostPermission, setHasPostPermission] = useState(false);
|
|
17
17
|
|
|
18
18
|
const isOnlyAdminCanPost =
|
|
19
19
|
community?.postSetting === CommunityPostSettings.ONLY_ADMIN_CAN_POST;
|
|
20
20
|
|
|
21
21
|
useEffect(() => {
|
|
22
|
+
if (isVisitorOrBot) return;
|
|
22
23
|
if (!community?.communityId || !client?.userId) return;
|
|
23
24
|
|
|
24
25
|
CommunityRepository.Membership.getMembers(
|
|
@@ -41,6 +42,7 @@ export function usePostPermission({ community }: UsePostPermissionParams) {
|
|
|
41
42
|
client?.userId,
|
|
42
43
|
isOnlyAdminCanPost,
|
|
43
44
|
community?.isJoined,
|
|
45
|
+
isVisitorOrBot,
|
|
44
46
|
]);
|
|
45
47
|
|
|
46
48
|
return hasPostPermission;
|