@amityco/react-native-social-uikit 4.0.0-RC18 → 4.0.0-RC19
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/snippet/AmityGlobalFeedComponent.js +6 -1
- package/lib/commonjs/snippet/AmityGlobalFeedComponent.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityCommunityHeaderComponent/AmityCommunityHeaderComponent.js +3 -3
- package/lib/commonjs/v4/PublicApi/Components/AmityCommunityHeaderComponent/AmityCommunityHeaderComponent.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.js +5 -7
- package/lib/commonjs/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.js +23 -3
- package/lib/commonjs/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.js +11 -17
- package/lib/commonjs/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/DetailStyle.js +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/DetailStyle.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/FeedStyle.js +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/FeedStyle.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.js +8 -23
- package/lib/commonjs/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.js +8 -2
- package/lib/commonjs/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.js.map +1 -1
- package/lib/commonjs/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.js +21 -29
- package/lib/commonjs/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.js.map +1 -1
- package/lib/commonjs/v4/component/CommunityRowItem/CommunityRowItem.js +5 -4
- package/lib/commonjs/v4/component/CommunityRowItem/CommunityRowItem.js.map +1 -1
- package/lib/commonjs/v4/component/Social/CommentList/CommentList.js +8 -12
- package/lib/commonjs/v4/component/Social/CommentList/CommentList.js.map +1 -1
- package/lib/commonjs/v4/component/TargetSelectionPage/TargetItem/TargetItem.js +4 -2
- package/lib/commonjs/v4/component/TargetSelectionPage/TargetItem/TargetItem.js.map +1 -1
- package/lib/commonjs/v4/component/TargetSelectionPage/TargetSelectionPage.js +1 -0
- package/lib/commonjs/v4/component/TargetSelectionPage/TargetSelectionPage.js.map +1 -1
- package/lib/commonjs/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js +8 -3
- package/lib/commonjs/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js.map +1 -1
- package/lib/commonjs/v4/elements/CommunityRowImage/CommunityRowImage.js +4 -32
- package/lib/commonjs/v4/elements/CommunityRowImage/CommunityRowImage.js.map +1 -1
- package/lib/commonjs/v4/features/community/Setting/hooks/useCommunitySetting.js +6 -3
- package/lib/commonjs/v4/features/community/Setting/hooks/useCommunitySetting.js.map +1 -1
- package/lib/commonjs/v4/{component/CommunityCategoryChips/CommunityCategoryChips.js → features/feed/components/CommunityCategories/CommunityCategories.js} +19 -21
- package/lib/commonjs/v4/features/feed/components/CommunityCategories/CommunityCategories.js.map +1 -0
- package/lib/commonjs/v4/features/feed/components/CommunityCategories/index.js +13 -0
- package/lib/commonjs/v4/features/feed/components/CommunityCategories/index.js.map +1 -0
- package/lib/commonjs/v4/{component/CommunityCategoryChips → features/feed/components/CommunityCategories}/styles.js +7 -2
- package/lib/commonjs/v4/features/feed/components/CommunityCategories/styles.js.map +1 -0
- package/lib/commonjs/v4/features/feed/components/index.js +17 -0
- package/lib/commonjs/v4/features/feed/components/index.js.map +1 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/CommunityCategory.js +42 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/CommunityCategory.js.map +1 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/index.js +13 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/index.js.map +1 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/styles.js +29 -0
- package/lib/commonjs/v4/features/feed/elements/CommunityCategory/styles.js.map +1 -0
- package/lib/commonjs/v4/features/feed/elements/index.js +17 -0
- package/lib/commonjs/v4/features/feed/elements/index.js.map +1 -0
- package/lib/commonjs/v4/hook/useCustomRankingGlobalFeed.js +33 -38
- package/lib/commonjs/v4/hook/useCustomRankingGlobalFeed.js.map +1 -1
- package/lib/commonjs/v4/hook/usePaginator.js +11 -16
- package/lib/commonjs/v4/hook/usePaginator.js.map +1 -1
- package/lib/commonjs/v4/routes/AmitySocialUIKitV4Navigator.js +1 -0
- package/lib/commonjs/v4/routes/AmitySocialUIKitV4Navigator.js.map +1 -1
- package/lib/commonjs/v4/screen/FollowerList/Components/FollowerListItem.js +1 -1
- package/lib/commonjs/v4/screen/FollowerList/Components/FollowerListItem.js.map +1 -1
- package/lib/module/snippet/AmityGlobalFeedComponent.js +6 -1
- package/lib/module/snippet/AmityGlobalFeedComponent.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityCommunityHeaderComponent/AmityCommunityHeaderComponent.js +3 -3
- package/lib/module/v4/PublicApi/Components/AmityCommunityHeaderComponent/AmityCommunityHeaderComponent.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.js +6 -8
- package/lib/module/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.js +23 -3
- package/lib/module/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.js +11 -17
- package/lib/module/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/DetailStyle.js +1 -1
- package/lib/module/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/DetailStyle.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/FeedStyle.js +1 -1
- package/lib/module/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/FeedStyle.js.map +1 -1
- package/lib/module/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.js +9 -23
- package/lib/module/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.js.map +1 -1
- package/lib/module/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.js +8 -2
- package/lib/module/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.js.map +1 -1
- package/lib/module/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.js +23 -31
- package/lib/module/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.js.map +1 -1
- package/lib/module/v4/component/CommunityRowItem/CommunityRowItem.js +5 -4
- package/lib/module/v4/component/CommunityRowItem/CommunityRowItem.js.map +1 -1
- package/lib/module/v4/component/Social/CommentList/CommentList.js +8 -12
- package/lib/module/v4/component/Social/CommentList/CommentList.js.map +1 -1
- package/lib/module/v4/component/TargetSelectionPage/TargetItem/TargetItem.js +4 -2
- package/lib/module/v4/component/TargetSelectionPage/TargetItem/TargetItem.js.map +1 -1
- package/lib/module/v4/component/TargetSelectionPage/TargetSelectionPage.js +1 -0
- package/lib/module/v4/component/TargetSelectionPage/TargetSelectionPage.js.map +1 -1
- package/lib/module/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js +8 -3
- package/lib/module/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.js.map +1 -1
- package/lib/module/v4/elements/CommunityRowImage/CommunityRowImage.js +6 -34
- package/lib/module/v4/elements/CommunityRowImage/CommunityRowImage.js.map +1 -1
- package/lib/module/v4/features/community/Setting/hooks/useCommunitySetting.js +6 -3
- package/lib/module/v4/features/community/Setting/hooks/useCommunitySetting.js.map +1 -1
- package/lib/module/v4/{component/CommunityCategoryChips/CommunityCategoryChips.js → features/feed/components/CommunityCategories/CommunityCategories.js} +18 -19
- package/lib/module/v4/features/feed/components/CommunityCategories/CommunityCategories.js.map +1 -0
- package/lib/module/v4/features/feed/components/CommunityCategories/index.js +2 -0
- package/lib/module/v4/features/feed/components/CommunityCategories/index.js.map +1 -0
- package/lib/module/v4/{component/CommunityCategoryChips → features/feed/components/CommunityCategories}/styles.js +7 -2
- package/lib/module/v4/features/feed/components/CommunityCategories/styles.js.map +1 -0
- package/lib/module/v4/features/feed/components/index.js +2 -0
- package/lib/module/v4/features/feed/components/index.js.map +1 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/CommunityCategory.js +35 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/CommunityCategory.js.map +1 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/index.js +2 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/index.js.map +1 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/styles.js +22 -0
- package/lib/module/v4/features/feed/elements/CommunityCategory/styles.js.map +1 -0
- package/lib/module/v4/features/feed/elements/index.js +2 -0
- package/lib/module/v4/features/feed/elements/index.js.map +1 -0
- package/lib/module/v4/hook/useCustomRankingGlobalFeed.js +34 -39
- package/lib/module/v4/hook/useCustomRankingGlobalFeed.js.map +1 -1
- package/lib/module/v4/hook/usePaginator.js +12 -17
- package/lib/module/v4/hook/usePaginator.js.map +1 -1
- package/lib/module/v4/routes/AmitySocialUIKitV4Navigator.js +1 -0
- package/lib/module/v4/routes/AmitySocialUIKitV4Navigator.js.map +1 -1
- package/lib/module/v4/screen/FollowerList/Components/FollowerListItem.js +1 -1
- package/lib/module/v4/screen/FollowerList/Components/FollowerListItem.js.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.d.ts +4 -0
- package/lib/typescript/src/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.d.ts.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.d.ts +1 -0
- package/lib/typescript/src/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.d.ts.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.d.ts.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.d.ts.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.d.ts.map +1 -1
- package/lib/typescript/src/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.d.ts.map +1 -1
- package/lib/typescript/src/v4/component/Social/CommentList/CommentList.d.ts.map +1 -1
- package/lib/typescript/src/v4/component/TargetSelectionPage/TargetItem/TargetItem.d.ts +2 -1
- package/lib/typescript/src/v4/component/TargetSelectionPage/TargetItem/TargetItem.d.ts.map +1 -1
- package/lib/typescript/src/v4/component/TargetSelectionPage/TargetSelectionPage.d.ts.map +1 -1
- package/lib/typescript/src/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.d.ts.map +1 -1
- package/lib/typescript/src/v4/elements/CommunityRowImage/CommunityRowImage.d.ts +1 -1
- package/lib/typescript/src/v4/elements/CommunityRowImage/CommunityRowImage.d.ts.map +1 -1
- package/lib/typescript/src/v4/features/community/Setting/hooks/useCommunitySetting.d.ts.map +1 -1
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/CommunityCategories.d.ts +12 -0
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/CommunityCategories.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/index.d.ts +2 -0
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/index.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/styles.d.ts +30 -0
- package/lib/typescript/src/v4/features/feed/components/CommunityCategories/styles.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/components/index.d.ts +2 -0
- package/lib/typescript/src/v4/features/feed/components/index.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/CommunityCategory.d.ts +12 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/CommunityCategory.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/index.d.ts +2 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/index.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/styles.d.ts +17 -0
- package/lib/typescript/src/v4/features/feed/elements/CommunityCategory/styles.d.ts.map +1 -0
- package/lib/typescript/src/v4/features/feed/elements/index.d.ts +2 -0
- package/lib/typescript/src/v4/features/feed/elements/index.d.ts.map +1 -0
- package/lib/typescript/src/v4/hook/useCustomRankingGlobalFeed.d.ts +6 -1
- package/lib/typescript/src/v4/hook/useCustomRankingGlobalFeed.d.ts.map +1 -1
- package/lib/typescript/src/v4/hook/usePaginator.d.ts.map +1 -1
- package/lib/typescript/src/v4/routes/AmitySocialUIKitV4Navigator.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/snippet/AmityGlobalFeedComponent.tsx +6 -1
- package/src/v4/PublicApi/Components/AmityCommunityHeaderComponent/AmityCommunityHeaderComponent.tsx +3 -3
- package/src/v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent.tsx +9 -6
- package/src/v4/PublicApi/Components/AmityNewsFeedComponent/AmityNewsFeedComponent.tsx +27 -2
- package/src/v4/PublicApi/Components/AmityPostCommentComponent/AmityPostCommentComponent.tsx +29 -36
- package/src/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/DetailStyle.tsx +2 -2
- package/src/v4/PublicApi/Components/AmityPostEngagementActionsComponent/Components/FeedStyle.tsx +1 -1
- package/src/v4/PublicApi/Components/AmityRecommenedCommunityComponent/RecommenedCommunityItems/RecommenedCommunityItems.tsx +8 -24
- package/src/v4/PublicApi/Pages/AmityCommunityProfilePage/AmityCommunityProfilePage.tsx +9 -2
- package/src/v4/PublicApi/Pages/AmitySocialHomePage/AmitySocialHomePage.tsx +27 -33
- package/src/v4/component/CommunityRowItem/CommunityRowItem.tsx +4 -4
- package/src/v4/component/Social/CommentList/CommentList.tsx +25 -29
- package/src/v4/component/TargetSelectionPage/TargetItem/TargetItem.tsx +3 -0
- package/src/v4/component/TargetSelectionPage/TargetSelectionPage.tsx +1 -0
- package/src/v4/elements/CommunityJoinButtonElement/CommunityJoinButtonElement.tsx +6 -2
- package/src/v4/elements/CommunityRowImage/CommunityRowImage.tsx +7 -34
- package/src/v4/features/community/Setting/hooks/useCommunitySetting.ts +4 -2
- package/src/v4/{component/CommunityCategoryChips/CommunityCategoryChips.tsx → features/feed/components/CommunityCategories/CommunityCategories.tsx} +20 -22
- package/src/v4/features/feed/components/CommunityCategories/index.ts +1 -0
- package/src/v4/{component/CommunityCategoryChips → features/feed/components/CommunityCategories}/styles.ts +4 -2
- package/src/v4/features/feed/components/index.ts +1 -0
- package/src/v4/features/feed/elements/CommunityCategory/CommunityCategory.tsx +45 -0
- package/src/v4/features/feed/elements/CommunityCategory/index.ts +1 -0
- package/src/v4/features/feed/elements/CommunityCategory/styles.ts +20 -0
- package/src/v4/features/feed/elements/index.ts +1 -0
- package/src/v4/hook/useCustomRankingGlobalFeed.ts +47 -47
- package/src/v4/hook/usePaginator.ts +20 -23
- package/src/v4/routes/AmitySocialUIKitV4Navigator.tsx +1 -0
- package/src/v4/screen/FollowerList/Components/FollowerListItem.tsx +1 -1
- package/lib/commonjs/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.js +0 -38
- package/lib/commonjs/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.js.map +0 -1
- package/lib/commonjs/v4/component/CommunityCategoryChips/CommunityCategoryChips.js.map +0 -1
- package/lib/commonjs/v4/component/CommunityCategoryChips/styles.js.map +0 -1
- package/lib/commonjs/v4/elements/CommunityCatetory/CommunityCategory.js +0 -38
- package/lib/commonjs/v4/elements/CommunityCatetory/CommunityCategory.js.map +0 -1
- package/lib/module/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.js +0 -30
- package/lib/module/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.js.map +0 -1
- package/lib/module/v4/component/CommunityCategoryChips/CommunityCategoryChips.js.map +0 -1
- package/lib/module/v4/component/CommunityCategoryChips/styles.js.map +0 -1
- package/lib/module/v4/elements/CommunityCatetory/CommunityCategory.js +0 -31
- package/lib/module/v4/elements/CommunityCatetory/CommunityCategory.js.map +0 -1
- package/lib/typescript/src/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.d.ts +0 -11
- package/lib/typescript/src/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.d.ts.map +0 -1
- package/lib/typescript/src/v4/component/CommunityCategoryChips/CommunityCategoryChips.d.ts +0 -11
- package/lib/typescript/src/v4/component/CommunityCategoryChips/CommunityCategoryChips.d.ts.map +0 -1
- package/lib/typescript/src/v4/component/CommunityCategoryChips/styles.d.ts +0 -27
- package/lib/typescript/src/v4/component/CommunityCategoryChips/styles.d.ts.map +0 -1
- package/lib/typescript/src/v4/elements/CommunityCatetory/CommunityCategory.d.ts +0 -12
- package/lib/typescript/src/v4/elements/CommunityCatetory/CommunityCategory.d.ts.map +0 -1
- package/src/v4/component/CommunityCategoryChips/CommunityCategoryChip/CommunityCategoryChip.tsx +0 -47
- package/src/v4/elements/CommunityCatetory/CommunityCategory.tsx +0 -41
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
} from 'react-native';
|
|
10
10
|
import React, { FC, useEffect, useState, useRef, memo } from 'react';
|
|
11
11
|
import { UserInterface, IMentionPosition } from '../../../../types';
|
|
12
|
-
import { getAmityUser } from '../../../../providers/user-provider';
|
|
13
12
|
import { CommentRepository } from '@amityco/ts-sdk-react-native';
|
|
14
13
|
import CommentListItem from '../CommentListItem/CommentListItem';
|
|
15
14
|
import {
|
|
@@ -103,10 +102,10 @@ const CommentList: FC<ICommentListProp> = ({
|
|
|
103
102
|
referenceType: postType,
|
|
104
103
|
limit: commentListLimit,
|
|
105
104
|
},
|
|
106
|
-
|
|
105
|
+
({ error, loading, data, hasNextPage, onNextPage }) => {
|
|
107
106
|
if (error) return;
|
|
108
107
|
if (!loading) {
|
|
109
|
-
data && data.length > 0 &&
|
|
108
|
+
data && data.length > 0 && queryComment(data);
|
|
110
109
|
onNextPageRef.current = hasNextPage ? onNextPage : null;
|
|
111
110
|
}
|
|
112
111
|
}
|
|
@@ -129,34 +128,31 @@ const CommentList: FC<ICommentListProp> = ({
|
|
|
129
128
|
}, [inputMessage]);
|
|
130
129
|
|
|
131
130
|
const queryComment = async (comments: Amity.InternalComment[]) => {
|
|
132
|
-
const formattedCommentList =
|
|
133
|
-
|
|
134
|
-
const { userObject } = await getAmityUser(item.userId);
|
|
135
|
-
let formattedUserObject: UserInterface;
|
|
131
|
+
const formattedCommentList = comments.map((item: Amity.Comment) => {
|
|
132
|
+
let formattedUserObject: UserInterface;
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
134
|
+
formattedUserObject = {
|
|
135
|
+
userId: item?.creator?.userId,
|
|
136
|
+
displayName: item?.creator?.displayName,
|
|
137
|
+
avatarFileId: item?.creator?.avatarFileId,
|
|
138
|
+
};
|
|
142
139
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
140
|
+
return {
|
|
141
|
+
commentId: item.commentId,
|
|
142
|
+
data: item.data as Record<string, any>,
|
|
143
|
+
dataType: item.dataType || 'text',
|
|
144
|
+
myReactions: item.myReactions as string[],
|
|
145
|
+
reactions: item.reactions as Record<string, number>,
|
|
146
|
+
user: formattedUserObject as UserInterface,
|
|
147
|
+
updatedAt: item.updatedAt,
|
|
148
|
+
editedAt: item.editedAt,
|
|
149
|
+
createdAt: item.createdAt,
|
|
150
|
+
childrenComment: item.children,
|
|
151
|
+
childrenNumber: item.childrenNumber,
|
|
152
|
+
referenceId: item.referenceId,
|
|
153
|
+
mentionPosition: item?.metadata?.mentioned ?? [],
|
|
154
|
+
};
|
|
155
|
+
});
|
|
160
156
|
setCommentList([...formattedCommentList]);
|
|
161
157
|
};
|
|
162
158
|
|
|
@@ -18,6 +18,7 @@ interface ITargetItem {
|
|
|
18
18
|
isBadgeShow?: boolean;
|
|
19
19
|
isPrivate?: boolean;
|
|
20
20
|
onSelect: () => void;
|
|
21
|
+
avatarCustomUrl?: string;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
const TargetItem = ({
|
|
@@ -30,6 +31,7 @@ const TargetItem = ({
|
|
|
30
31
|
isBadgeShow,
|
|
31
32
|
isPrivate,
|
|
32
33
|
onSelect,
|
|
34
|
+
avatarCustomUrl,
|
|
33
35
|
}: ITargetItem) => {
|
|
34
36
|
const theme = useTheme() as MyMD3Theme;
|
|
35
37
|
|
|
@@ -72,6 +74,7 @@ const TargetItem = ({
|
|
|
72
74
|
elementID={avatarElementId}
|
|
73
75
|
avatarId={avatarFileId}
|
|
74
76
|
targetType="community"
|
|
77
|
+
avatarCustomUrl={avatarCustomUrl}
|
|
75
78
|
/>
|
|
76
79
|
{isPrivate && (
|
|
77
80
|
<ImageElement
|
|
@@ -27,9 +27,13 @@ const CommunityJoinButton: FC<CommunityJoinButtonType> = ({
|
|
|
27
27
|
elementId: ElementID.community_join_button,
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const { refresh } = useCustomRankingGlobalFeed(
|
|
30
|
+
const { refresh, globalFeedPosts } = useCustomRankingGlobalFeed({
|
|
31
|
+
enabled: false,
|
|
32
|
+
});
|
|
31
33
|
const { joinCommunity, isPending } = useJoinCommunity({
|
|
32
|
-
onSuccess: () =>
|
|
34
|
+
onSuccess: () => {
|
|
35
|
+
globalFeedPosts.length === 0 && refresh();
|
|
36
|
+
},
|
|
33
37
|
});
|
|
34
38
|
|
|
35
39
|
const handleJoinCommunity = () => {
|
|
@@ -1,67 +1,40 @@
|
|
|
1
|
-
import React, { FC, memo
|
|
1
|
+
import React, { FC, memo } from 'react';
|
|
2
2
|
import LinearGradient from 'react-native-linear-gradient';
|
|
3
3
|
import { ComponentID, ElementID, PageID } from '../../enum';
|
|
4
|
-
import { useAmityElement
|
|
4
|
+
import { useAmityElement } from '../../hook';
|
|
5
5
|
import { Image, View } from 'react-native';
|
|
6
6
|
import { useStyles } from './styles';
|
|
7
7
|
import { Typography } from '../../component/Typography/Typography';
|
|
8
8
|
import { SvgXml } from 'react-native-svg';
|
|
9
9
|
import { community as communityIcon } from '../../assets/icons';
|
|
10
|
+
import { getFileUrlWithSize } from '../../../v4/utils';
|
|
10
11
|
|
|
11
12
|
type CommunityRowImageyProps = {
|
|
12
|
-
|
|
13
|
+
fileUrl?: string;
|
|
13
14
|
pageId?: PageID;
|
|
14
15
|
componentId?: ComponentID;
|
|
15
16
|
label?: string;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const CommunityRowImagey: FC<CommunityRowImageyProps> = ({
|
|
19
|
-
|
|
20
|
+
fileUrl,
|
|
20
21
|
pageId = PageID.WildCardPage,
|
|
21
22
|
componentId = ComponentID.WildCardComponent,
|
|
22
23
|
label,
|
|
23
24
|
}) => {
|
|
24
|
-
// TODO: add state loading and loading skeleton
|
|
25
25
|
const elementId = ElementID.community_row_image;
|
|
26
26
|
const styles = useStyles();
|
|
27
|
-
const [image, setImage] = useState<string | undefined>(undefined);
|
|
28
27
|
const { accessibilityId } = useAmityElement({
|
|
29
28
|
pageId,
|
|
30
29
|
componentId,
|
|
31
30
|
elementId,
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
const { uri } = useConfigImageUri({
|
|
35
|
-
configPath: {
|
|
36
|
-
page: pageId,
|
|
37
|
-
component: componentId,
|
|
38
|
-
element: elementId,
|
|
39
|
-
},
|
|
40
|
-
configKey: 'image',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const { getImage } = useFile();
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const getImageUrl = async () => {
|
|
47
|
-
if (!fileId) return;
|
|
48
|
-
|
|
49
|
-
if (!fileId && uri) {
|
|
50
|
-
setImage(uri);
|
|
51
|
-
} else if (fileId) {
|
|
52
|
-
const url = await getImage({ fileId });
|
|
53
|
-
setImage(url);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
getImageUrl();
|
|
58
|
-
}, [uri, fileId, getImage]);
|
|
59
|
-
|
|
60
33
|
return (
|
|
61
34
|
<View testID={accessibilityId} style={styles.container}>
|
|
62
|
-
{
|
|
35
|
+
{fileUrl ? (
|
|
63
36
|
<Image
|
|
64
|
-
source={{ uri:
|
|
37
|
+
source={{ uri: getFileUrlWithSize(fileUrl) }}
|
|
65
38
|
style={styles.image}
|
|
66
39
|
resizeMode="cover"
|
|
67
40
|
/>
|
|
@@ -18,7 +18,9 @@ export function useCommunitySetting(community: Amity.Community) {
|
|
|
18
18
|
>();
|
|
19
19
|
const { AmityCommunitySettingPageBehavior } = useBehaviour();
|
|
20
20
|
const { showToast } = useToast();
|
|
21
|
-
const { refresh } = useCustomRankingGlobalFeed(
|
|
21
|
+
const { refresh, globalFeedPosts } = useCustomRankingGlobalFeed({
|
|
22
|
+
enabled: false,
|
|
23
|
+
});
|
|
22
24
|
|
|
23
25
|
const { mutate: leaveCommunity } = useMutation({
|
|
24
26
|
mutationFn: async () =>
|
|
@@ -26,7 +28,7 @@ export function useCommunitySetting(community: Amity.Community) {
|
|
|
26
28
|
onSuccess: () => {
|
|
27
29
|
navigation.goBack();
|
|
28
30
|
showToast({ message: 'Successfully left the group', type: 'success' });
|
|
29
|
-
setTimeout(() => refresh(), 3000);
|
|
31
|
+
globalFeedPosts.length === 0 && setTimeout(() => refresh(), 3000);
|
|
30
32
|
},
|
|
31
33
|
onError: (error) => {
|
|
32
34
|
if (error.message.includes(ERROR_CODE.ONLY_ONE_MODERATOR)) {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, View, ViewProps, ScrollView } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
import type { MyMD3Theme } from 'src/providers/amity-ui-kit-provider';
|
|
3
|
+
import { CommunityCategory } from '../../elements/CommunityCategory/CommunityCategory';
|
|
5
4
|
import { useStyles } from './styles';
|
|
5
|
+
import { ComponentID, PageID } from '../../../../enum';
|
|
6
6
|
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
type CommunityCategoriesProps = ViewProps & {
|
|
8
|
+
categories: Amity.Category[];
|
|
9
|
+
pageId?: PageID;
|
|
10
|
+
componentId?: ComponentID;
|
|
10
11
|
allVisible?: boolean;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const MAX_VISIBLE_CATEGORIES = 2;
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
themeStyles,
|
|
16
|
+
export function CommunityCategories({
|
|
17
|
+
categories,
|
|
18
18
|
allVisible,
|
|
19
19
|
...props
|
|
20
|
-
})
|
|
21
|
-
const styles = useStyles(
|
|
22
|
-
const visibleCategories =
|
|
23
|
-
const hiddenCategoriesCount =
|
|
20
|
+
}: CommunityCategoriesProps) {
|
|
21
|
+
const { styles } = useStyles();
|
|
22
|
+
const visibleCategories = categories.slice(0, MAX_VISIBLE_CATEGORIES);
|
|
23
|
+
const hiddenCategoriesCount = categories.length - MAX_VISIBLE_CATEGORIES;
|
|
24
24
|
const showMoreText =
|
|
25
25
|
hiddenCategoriesCount > 0 ? `+${hiddenCategoriesCount}` : '';
|
|
26
26
|
const showMore = hiddenCategoriesCount > 0;
|
|
@@ -51,7 +51,7 @@ export const CommunityCategoryChips: React.FC<CommunityCategoryChipsProps> = ({
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// Choose all categories or just the visible ones based on allVisible
|
|
54
|
-
const displayCategories = allVisible ?
|
|
54
|
+
const displayCategories = allVisible ? categories : visibleCategories;
|
|
55
55
|
// Only show more indicator if not showing all categories
|
|
56
56
|
const displayShowMore = !allVisible && showMore;
|
|
57
57
|
|
|
@@ -63,23 +63,21 @@ export const CommunityCategoryChips: React.FC<CommunityCategoryChipsProps> = ({
|
|
|
63
63
|
showsHorizontalScrollIndicator={false}
|
|
64
64
|
contentContainerStyle={styles.scrollableContainer}
|
|
65
65
|
>
|
|
66
|
-
{displayCategories.map((
|
|
67
|
-
<
|
|
66
|
+
{displayCategories.map((category, index) => (
|
|
67
|
+
<CommunityCategory
|
|
68
68
|
key={index}
|
|
69
|
-
|
|
69
|
+
categoryName={category.name}
|
|
70
70
|
maxWidth={getMaxWidthForItem(displayCategories.length)}
|
|
71
|
-
themeStyles={themeStyles}
|
|
72
71
|
/>
|
|
73
72
|
))}
|
|
74
73
|
</ScrollView>
|
|
75
74
|
) : (
|
|
76
75
|
<>
|
|
77
|
-
{displayCategories.map((
|
|
78
|
-
<
|
|
76
|
+
{displayCategories.map((category, index) => (
|
|
77
|
+
<CommunityCategory
|
|
79
78
|
key={index}
|
|
80
|
-
|
|
79
|
+
categoryName={category.name}
|
|
81
80
|
maxWidth={getMaxWidthForItem(displayCategories.length)}
|
|
82
|
-
themeStyles={themeStyles}
|
|
83
81
|
/>
|
|
84
82
|
))}
|
|
85
83
|
{displayShowMore && (
|
|
@@ -91,4 +89,4 @@ export const CommunityCategoryChips: React.FC<CommunityCategoryChipsProps> = ({
|
|
|
91
89
|
)}
|
|
92
90
|
</View>
|
|
93
91
|
);
|
|
94
|
-
}
|
|
92
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CommunityCategories } from './CommunityCategories';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useTheme } from 'react-native-paper';
|
|
2
3
|
import { MyMD3Theme } from 'src/providers/amity-ui-kit-provider';
|
|
3
4
|
|
|
4
|
-
export const useStyles = (
|
|
5
|
+
export const useStyles = () => {
|
|
6
|
+
const theme = useTheme<MyMD3Theme>();
|
|
5
7
|
const styles = StyleSheet.create({
|
|
6
8
|
container: {
|
|
7
9
|
flexDirection: 'row',
|
|
@@ -27,5 +29,5 @@ export const useStyles = (theme: MyMD3Theme) => {
|
|
|
27
29
|
color: theme.colors.base,
|
|
28
30
|
},
|
|
29
31
|
});
|
|
30
|
-
return styles;
|
|
32
|
+
return { styles, theme };
|
|
31
33
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CommunityCategories';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DimensionValue, Text, View } from 'react-native';
|
|
3
|
+
import { useStyles } from './styles';
|
|
4
|
+
import { useAmityElement } from '../../../../hook';
|
|
5
|
+
import { ComponentID, ElementID, PageID } from '../../../../enum';
|
|
6
|
+
|
|
7
|
+
type CommunityCategoryProps = {
|
|
8
|
+
categoryName: string;
|
|
9
|
+
style?: object;
|
|
10
|
+
maxWidth?: number | string;
|
|
11
|
+
pageId?: PageID;
|
|
12
|
+
componentId?: ComponentID;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function CommunityCategory({
|
|
16
|
+
categoryName,
|
|
17
|
+
style,
|
|
18
|
+
maxWidth,
|
|
19
|
+
pageId,
|
|
20
|
+
componentId,
|
|
21
|
+
}: CommunityCategoryProps) {
|
|
22
|
+
const { styles } = useStyles();
|
|
23
|
+
const { accessibilityId, isExcluded } = useAmityElement({
|
|
24
|
+
pageId,
|
|
25
|
+
componentId,
|
|
26
|
+
elementId: ElementID.community_category,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (isExcluded) return null;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<View
|
|
33
|
+
testID={accessibilityId}
|
|
34
|
+
style={[
|
|
35
|
+
styles.chipContainer,
|
|
36
|
+
maxWidth ? { maxWidth: maxWidth as DimensionValue } : null,
|
|
37
|
+
style,
|
|
38
|
+
]}
|
|
39
|
+
>
|
|
40
|
+
<Text style={styles.chipText} numberOfLines={1}>
|
|
41
|
+
{categoryName}
|
|
42
|
+
</Text>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CommunityCategory } from './CommunityCategory';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { useTheme } from 'react-native-paper';
|
|
3
|
+
import { MyMD3Theme } from 'src/providers/amity-ui-kit-provider';
|
|
4
|
+
|
|
5
|
+
export const useStyles = () => {
|
|
6
|
+
const theme = useTheme<MyMD3Theme>();
|
|
7
|
+
const styles = StyleSheet.create({
|
|
8
|
+
chipContainer: {
|
|
9
|
+
backgroundColor: theme.colors.baseShade4,
|
|
10
|
+
paddingHorizontal: 6,
|
|
11
|
+
borderRadius: 20,
|
|
12
|
+
},
|
|
13
|
+
chipText: {
|
|
14
|
+
fontSize: 13,
|
|
15
|
+
lineHeight: 18,
|
|
16
|
+
color: theme.colors.base,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
return { styles, theme };
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CommunityCategory';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FeedRepository,
|
|
3
|
+
PostStructureType,
|
|
4
|
+
} from '@amityco/ts-sdk-react-native';
|
|
2
5
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { InteractionManager } from 'react-native';
|
|
3
7
|
import globalFeedSlice from '../../redux/slices/globalfeedSlice';
|
|
4
8
|
import { globalFeedPageLimit } from '../../v4/PublicApi/Components/AmityGlobalFeedComponent/AmityGlobalFeedComponent';
|
|
5
9
|
import {
|
|
@@ -17,11 +21,18 @@ export const isAmityAd = (
|
|
|
17
21
|
return (item as Amity.Ad)?.adId !== undefined;
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
type UseCustomRankingGlobalFeed = {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const useCustomRankingGlobalFeed = ({
|
|
29
|
+
enabled = true,
|
|
30
|
+
}: UseCustomRankingGlobalFeed = {}) => {
|
|
21
31
|
const { isConnected } = useAuth();
|
|
22
32
|
const dispatch = useUIKitDispatch();
|
|
23
33
|
const unsubscribeRef = useRef<() => void | null>(null);
|
|
24
34
|
const onNextPageRef = useRef<() => void | null>(null);
|
|
35
|
+
const interactionHandleRef = useRef<{ cancel: () => void } | null>(null);
|
|
25
36
|
|
|
26
37
|
const { setNewGlobalFeed } = globalFeedSlice.actions;
|
|
27
38
|
|
|
@@ -39,69 +50,57 @@ export const useCustomRankingGlobalFeed = () => {
|
|
|
39
50
|
getItemId: (item) => (item as Amity.Post).postId.toString(),
|
|
40
51
|
});
|
|
41
52
|
|
|
42
|
-
const processPosts = async (posts: Amity.Post[]) => {
|
|
43
|
-
const results = await Promise.all(
|
|
44
|
-
posts.map((post) => {
|
|
45
|
-
if (post?.children.length > 0) {
|
|
46
|
-
return new Promise((resolve) => {
|
|
47
|
-
const unsubscribe = PostRepository.getPost(
|
|
48
|
-
post?.children[0],
|
|
49
|
-
({ error: $error, loading, data }) => {
|
|
50
|
-
if (!$error && !loading) {
|
|
51
|
-
if (
|
|
52
|
-
data?.dataType === 'image' ||
|
|
53
|
-
data?.dataType === 'video' ||
|
|
54
|
-
data?.dataType === 'room' ||
|
|
55
|
-
data?.dataType === 'poll'
|
|
56
|
-
) {
|
|
57
|
-
resolve(post);
|
|
58
|
-
} else {
|
|
59
|
-
resolve(null);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
resolve(null);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
unsubscribe();
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
return post;
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return results.filter((result) => result !== null) as Amity.Post<any>[];
|
|
76
|
-
};
|
|
77
|
-
|
|
78
53
|
const fetchCustomRanking = useCallback(() => {
|
|
79
54
|
if (!isConnected) return null;
|
|
80
55
|
|
|
81
|
-
return FeedRepository.
|
|
56
|
+
return FeedRepository.getGlobalFeed(
|
|
82
57
|
{ limit: globalFeedPageLimit },
|
|
83
|
-
({ data, loading, error: $error, onNextPage }) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
processPosts(data).then((posts) => dispatch(setNewGlobalFeed(posts)));
|
|
58
|
+
({ data, loading: isLoading, error: $error, onNextPage }) => {
|
|
59
|
+
if (isLoading) {
|
|
60
|
+
setFetching(true);
|
|
61
|
+
return;
|
|
88
62
|
}
|
|
89
63
|
|
|
90
64
|
if (onNextPage) onNextPageRef.current = onNextPage;
|
|
91
|
-
|
|
92
65
|
if ($error) setError($error);
|
|
66
|
+
|
|
67
|
+
if (data) {
|
|
68
|
+
const filtered = data.filter(
|
|
69
|
+
(post) =>
|
|
70
|
+
post.structureType !== PostStructureType.AUDIO &&
|
|
71
|
+
post.structureType !== PostStructureType.FILE &&
|
|
72
|
+
post.structureType !== PostStructureType.MIXED
|
|
73
|
+
);
|
|
74
|
+
interactionHandleRef.current?.cancel();
|
|
75
|
+
interactionHandleRef.current =
|
|
76
|
+
InteractionManager.runAfterInteractions(() => {
|
|
77
|
+
dispatch(setNewGlobalFeed(filtered));
|
|
78
|
+
setFetching(false);
|
|
79
|
+
interactionHandleRef.current = null;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
setFetching(false);
|
|
83
|
+
}
|
|
93
84
|
}
|
|
94
85
|
);
|
|
95
86
|
}, [dispatch, setNewGlobalFeed, isConnected]);
|
|
96
87
|
|
|
97
88
|
useEffect(() => {
|
|
89
|
+
if (!enabled) return undefined;
|
|
90
|
+
|
|
98
91
|
unsubscribeRef.current = fetchCustomRanking();
|
|
99
92
|
|
|
100
|
-
return () =>
|
|
101
|
-
|
|
93
|
+
return () => {
|
|
94
|
+
unsubscribeRef.current?.();
|
|
95
|
+
interactionHandleRef.current?.cancel();
|
|
96
|
+
interactionHandleRef.current = null;
|
|
97
|
+
};
|
|
98
|
+
}, [fetchCustomRanking, enabled]);
|
|
102
99
|
|
|
103
100
|
const refresh = useCallback(() => {
|
|
104
101
|
if (unsubscribeRef.current) unsubscribeRef.current?.();
|
|
102
|
+
interactionHandleRef.current?.cancel();
|
|
103
|
+
interactionHandleRef.current = null;
|
|
105
104
|
onNextPageRef.current = null;
|
|
106
105
|
|
|
107
106
|
unsubscribeRef.current = fetchCustomRanking();
|
|
@@ -113,5 +112,6 @@ export const useCustomRankingGlobalFeed = () => {
|
|
|
113
112
|
itemWithAds,
|
|
114
113
|
onNextPage: onNextPageRef.current,
|
|
115
114
|
error,
|
|
115
|
+
globalFeedPosts: postList,
|
|
116
116
|
};
|
|
117
117
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useRef, useState, useTransition } from 'react';
|
|
2
2
|
import { AdEngine } from '../engine/AdEngine';
|
|
3
3
|
import {
|
|
4
4
|
useAdSettings,
|
|
5
5
|
useRecommendAds,
|
|
6
6
|
} from '../../v4/providers/AdEngineProvider';
|
|
7
|
-
import { useFocusEffect } from '@react-navigation/native';
|
|
8
7
|
|
|
9
8
|
type ItemWithAd<T> = [T] | [T, Amity.Ad];
|
|
10
9
|
|
|
@@ -41,21 +40,19 @@ export const usePaginatorCore = <T>({
|
|
|
41
40
|
newItems: T[],
|
|
42
41
|
newItemIds: Set<string>
|
|
43
42
|
): Array<ItemWithAd<T>> => {
|
|
43
|
+
const newItemsMap = new Map<string, T>(
|
|
44
|
+
newItems.map((item) => [getItemId(item), item])
|
|
45
|
+
);
|
|
44
46
|
return (itemWithAdsRef.current || [])
|
|
45
47
|
.map((itemWithAd) => {
|
|
46
48
|
const itemId = getItemId(itemWithAd[0]);
|
|
47
49
|
|
|
48
|
-
// Skip items not in new items list
|
|
49
50
|
if (!newItemIds.has(itemId)) {
|
|
50
51
|
return null;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
const updatedItem = newItems.find(
|
|
55
|
-
(newItem) => getItemId(newItem) === itemId
|
|
56
|
-
);
|
|
54
|
+
const updatedItem = newItemsMap.get(itemId);
|
|
57
55
|
|
|
58
|
-
// Update the item while preserving its ad (if any)
|
|
59
56
|
if (updatedItem) {
|
|
60
57
|
if (itemWithAd.length === 1) {
|
|
61
58
|
return [updatedItem] as [T];
|
|
@@ -86,13 +83,14 @@ export const usePaginatorCore = <T>({
|
|
|
86
83
|
topIndex: number,
|
|
87
84
|
prevItems: Array<ItemWithAd<T>>
|
|
88
85
|
): T[] => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
const prevItemIds = new Set<string>(
|
|
87
|
+
prevItems
|
|
88
|
+
.filter((item) => item && item[0])
|
|
89
|
+
.map((item) => getItemId(item[0]))
|
|
90
|
+
);
|
|
91
|
+
return newItems
|
|
92
|
+
.slice(topIndex)
|
|
93
|
+
.filter((newItem) => !prevItemIds.has(getItemId(newItem)));
|
|
96
94
|
};
|
|
97
95
|
|
|
98
96
|
const frequency = AdEngine.instance.getAdFrequencyByPlacement(placement);
|
|
@@ -256,6 +254,7 @@ export const usePaginatorApi = <T>(params: {
|
|
|
256
254
|
const [itemWithAds, setItemWithAds] = useState<
|
|
257
255
|
(Amity.Ad | T)[] | undefined
|
|
258
256
|
>();
|
|
257
|
+
const [_, startTransition] = useTransition();
|
|
259
258
|
|
|
260
259
|
const { items, isLoading, ...rest } = params;
|
|
261
260
|
const {
|
|
@@ -275,16 +274,14 @@ export const usePaginatorApi = <T>(params: {
|
|
|
275
274
|
setHasAppenedFirstRoundAds(false);
|
|
276
275
|
}, [coreReset]);
|
|
277
276
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (!adsLoaded || isLoading) return;
|
|
279
|
+
startTransition(() => {
|
|
282
280
|
const newItems = combineItemsWithAds(items);
|
|
283
|
-
|
|
284
281
|
setItemWithAds(newItems);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
);
|
|
282
|
+
});
|
|
283
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
284
|
+
}, [adsLoaded, items, isLoading]);
|
|
288
285
|
|
|
289
286
|
return { itemWithAds, reset };
|
|
290
287
|
};
|
|
@@ -70,7 +70,7 @@ const FollowerListItem: FC<FollowerListItemType> = ({
|
|
|
70
70
|
fileId: data.avatarFileId,
|
|
71
71
|
imageSize: ImageSizeState.small,
|
|
72
72
|
});
|
|
73
|
-
setAvatar(userAvatar ?? defaultAvatarUri);
|
|
73
|
+
setAvatar(data?.avatarCustomUrl ?? userAvatar ?? defaultAvatarUri);
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}, [getImage, userId]);
|