-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
102 show user related activities in profile (#713)
* Add user Activity on profile view * Add load more button and functionality * Remove redundant * Add mutual activities based on component state * Add user related activity functionality * Remove redundant * Write code cleaner * Correct typo * Corrected loading state on Activities, corrected loading more button behaviour * Correct PAGE_SIZE parameter * Add mutual activities on Organisation accounts
- Loading branch information
Showing
11 changed files
with
2,797 additions
and
1,101 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Box } from '@mui/material'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { DateTime } from 'luxon'; | ||
import PropTypes from 'prop-types'; | ||
import React, { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
|
||
import ActivityStream from '~/components/ActivityStream'; | ||
import { loadMoreActivitiesMutual } from '~/store/activity/actions'; | ||
import ActionTypes from '~/store/activity/types'; | ||
|
||
const useStyles = makeStyles(() => { | ||
return { | ||
activityContainer: { | ||
paddingBottom: '110px', | ||
}, | ||
}; | ||
}); | ||
|
||
const ProfileContentActivity = ({ address }) => { | ||
const classes = useStyles(); | ||
const dispatch = useDispatch(); | ||
const mutualActivities = useSelector( | ||
(state) => state.activity.mutualActivities.activities, | ||
); | ||
const isMoreAvailable = useSelector( | ||
(state) => state.activity.mutualActivities.isMoreAvailable, | ||
); | ||
const isLoadingMore = useSelector( | ||
(state) => state.activity.mutualActivities.isLoadingMore, | ||
); | ||
const mutualAddress = useSelector( | ||
(state) => state.activity.mutualActivities.mutualAddress, | ||
); | ||
|
||
useEffect(() => { | ||
if (mutualAddress !== address) { | ||
dispatch({ | ||
type: ActionTypes.ACTIVITIES_MUTUAL_RESET, | ||
}); | ||
|
||
Promise.all([ | ||
dispatch({ | ||
type: ActionTypes.ACTIVITIES_MUTUAL_ADDRESS_UPDATE, | ||
meta: { | ||
mutualAddress: address, | ||
}, | ||
}), | ||
dispatch(loadMoreActivitiesMutual(address, { fromOffsetZero: true })), | ||
]); | ||
} | ||
}, [address, mutualAddress]); //eslint-disable-line react-hooks/exhaustive-deps | ||
|
||
const currentTime = DateTime.now().toISO(); | ||
|
||
const handleLoadMore = () => { | ||
dispatch(loadMoreActivitiesMutual(address)); | ||
}; | ||
|
||
return ( | ||
<Box className={classes.activityContainer}> | ||
<ActivityStream | ||
activities={mutualActivities} | ||
isLoading={isLoadingMore} | ||
isMoreAvailable={isMoreAvailable} | ||
lastSeenAt={currentTime} | ||
onLoadMore={handleLoadMore} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
ProfileContentActivity.propTypes = { | ||
address: PropTypes.string, | ||
}; | ||
|
||
export default ProfileContentActivity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.