fix(ui): user profile page activity feed (#12226)

This commit is contained in:
Chirag Madlani 2023-06-29 17:21:55 +05:30 committed by GitHub
parent 70b76a34c1
commit f74004d9c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 54 deletions

View File

@ -57,7 +57,7 @@ const ActivityFeedListV1 = ({
} }
return ( return (
<div className="feed-list-container h-full p-y-md" id="feedData"> <div className="feed-list-container p-y-md m-b-sm" id="feedData">
{entityThread.length === 0 && ( {entityThread.length === 0 && (
<div <div
className="h-full p-x-md" className="h-full p-x-md"

View File

@ -51,13 +51,16 @@ import { ActivityFeedProviderContextType } from './ActivityFeedProviderContext.i
interface Props { interface Props {
children: ReactNode; children: ReactNode;
// To override current userId in case of User profile page
// Will update logic to ser userID from props later
user?: string;
} }
export const ActivityFeedContext = createContext( export const ActivityFeedContext = createContext(
{} as ActivityFeedProviderContextType {} as ActivityFeedProviderContextType
); );
const ActivityFeedProvider = ({ children }: Props) => { const ActivityFeedProvider = ({ children, user }: Props) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [entityThread, setEntityThread] = useState<Thread[]>([]); const [entityThread, setEntityThread] = useState<Thread[]>([]);
const [entityPaging, setEntityPaging] = useState<Paging>({} as Paging); const [entityPaging, setEntityPaging] = useState<Paging>({} as Paging);
@ -105,7 +108,11 @@ const ActivityFeedProvider = ({ children }: Props) => {
setLoading(true); setLoading(true);
const feedFilterType = filterType ?? FeedFilter.ALL; const feedFilterType = filterType ?? FeedFilter.ALL;
const userId = const userId =
feedFilterType === FeedFilter.ALL ? undefined : currentUser?.id; entityType === EntityType.USER_NAME
? user
: feedFilterType === FeedFilter.ALL
? undefined
: currentUser?.id;
const { data, paging } = await getAllFeeds( const { data, paging } = await getAllFeeds(
entityType !== EntityType.USER_NAME entityType !== EntityType.USER_NAME
@ -360,6 +367,7 @@ const ActivityFeedProvider = ({ children }: Props) => {
updateEditorFocus, updateEditorFocus,
setActiveThread, setActiveThread,
entityPaging, entityPaging,
userId: user ?? currentUser?.id ?? '',
}; };
}, [ }, [
entityThread, entityThread,
@ -379,6 +387,8 @@ const ActivityFeedProvider = ({ children }: Props) => {
updateEditorFocus, updateEditorFocus,
setActiveThread, setActiveThread,
entityPaging, entityPaging,
user,
currentUser,
]); ]);
return ( return (

View File

@ -31,6 +31,7 @@ export interface ActivityFeedProviderContextType {
focusReplyEditor: boolean; focusReplyEditor: boolean;
entityPaging: Paging; entityPaging: Paging;
setActiveThread: (thread?: Thread) => void; setActiveThread: (thread?: Thread) => void;
userId: string;
deleteFeed: ( deleteFeed: (
threadId: string, threadId: string,
postId: string, postId: string,

View File

@ -11,7 +11,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { Menu, Typography } from 'antd'; import { Menu, Typography } from 'antd';
import AppState from 'AppState';
import classNames from 'classnames'; import classNames from 'classnames';
import Loader from 'components/Loader/Loader'; import Loader from 'components/Loader/Loader';
import { TaskTab } from 'components/Task/TaskTab/TaskTab.component'; import { TaskTab } from 'components/Task/TaskTab/TaskTab.component';
@ -72,11 +71,6 @@ export const ActivityFeedTab = ({
const [allCount, setAllCount] = useState(0); const [allCount, setAllCount] = useState(0);
const [tasksCount, setTasksCount] = useState(0); const [tasksCount, setTasksCount] = useState(0);
const currentUser = useMemo(
() => AppState.getCurrentUserDetails(),
[AppState.userDetails, AppState.nonSecureUserDetails]
);
const { const {
postFeed, postFeed,
selectedThread, selectedThread,
@ -84,6 +78,7 @@ export const ActivityFeedTab = ({
entityThread, entityThread,
getFeedData, getFeedData,
loading, loading,
userId,
entityPaging, entityPaging,
} = useActivityFeedProvider(); } = useActivityFeedProvider();
@ -143,7 +138,6 @@ export const ActivityFeedTab = ({
} }
); );
} else { } else {
if (activeTab !== ActivityFeedTabs.TASKS) {
// count for task on userProfile page // count for task on userProfile page
getAllFeeds( getAllFeeds(
undefined, undefined,
@ -151,7 +145,7 @@ export const ActivityFeedTab = ({
ThreadType.Task, ThreadType.Task,
FeedFilter.OWNER, FeedFilter.OWNER,
undefined, undefined,
currentUser?.id userId
).then((res) => { ).then((res) => {
if (res) { if (res) {
setTasksCount(res.paging.total); setTasksCount(res.paging.total);
@ -159,9 +153,7 @@ export const ActivityFeedTab = ({
throw t('server.entity-feed-fetch-error'); throw t('server.entity-feed-fetch-error');
} }
}); });
}
if (activeTab !== ActivityFeedTabs.ALL) {
// count for all on userProfile page // count for all on userProfile page
getAllFeeds( getAllFeeds(
undefined, undefined,
@ -169,7 +161,7 @@ export const ActivityFeedTab = ({
ThreadType.Conversation, ThreadType.Conversation,
FeedFilter.OWNER, FeedFilter.OWNER,
undefined, undefined,
currentUser?.id userId
).then((res) => { ).then((res) => {
if (res) { if (res) {
setAllCount(res.paging.total); setAllCount(res.paging.total);
@ -178,22 +170,12 @@ export const ActivityFeedTab = ({
} }
}); });
} }
}
}; };
useEffect(() => { useEffect(() => {
fetchFeedsCount(); fetchFeedsCount();
}, []); }, []);
useEffect(() => {
if (isUserEntity && activeTab === ActivityFeedTabs.ALL && !allCount) {
setAllCount(entityPaging.total);
}
if (isUserEntity && activeTab === ActivityFeedTabs.TASKS && !tasksCount) {
setTasksCount(entityPaging.total);
}
});
const { feedFilter, threadType } = useMemo(() => { const { feedFilter, threadType } = useMemo(() => {
return { return {
threadType: threadType:
@ -371,6 +353,7 @@ export const ActivityFeedTab = ({
data-testid="observer-element" data-testid="observer-element"
id="observer-element" id="observer-element"
ref={elementRef as RefObject<HTMLDivElement>} ref={elementRef as RefObject<HTMLDivElement>}
style={{ height: '2px' }}
/> />
</div> </div>
<div className=" right-container"> <div className=" right-container">

View File

@ -736,7 +736,7 @@ const Users = ({
} }
case UserPageTabs.ACTIVITY: case UserPageTabs.ACTIVITY:
return ( return (
<ActivityFeedProvider> <ActivityFeedProvider user={userData.id}>
<ActivityFeedTab <ActivityFeedTab
entityType={EntityType.USER_NAME} entityType={EntityType.USER_NAME}
fqn={username} fqn={username}

View File

@ -20,7 +20,7 @@ import { LOGIN_SLIDE } from '../../constants/Login.constants';
const LoginCarousel = () => { const LoginCarousel = () => {
return ( return (
<div className="carousal-container" data-testid="carousel-container"> <div className="carousal-container" data-testid="carousel-container">
<Carousel autoplay dots autoplaySpeed={1500} easing="ease-in-out"> <Carousel autoplay dots autoplaySpeed={3000} easing="ease-in-out">
{LOGIN_SLIDE.map((data) => ( {LOGIN_SLIDE.map((data) => (
<div <div
className="text-center" className="text-center"