This repository was archived by the owner on Mar 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
infinite scroll for new members #397
Open
Ishikabaid
wants to merge
6
commits into
RealDevSquad:develop
Choose a base branch
from
Ishikabaid:infiniteScroll
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c9e2777
infinite scroll for new members
Ishikabaid 52a9c63
fixed members images
Ishikabaid df87f16
added react-waypoint
Ishikabaid 471f3e8
fixed search new members
Ishikabaid 40e8430
moved number to constants file
Ishikabaid fb0d052
resolved conflicts
Ishikabaid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -7,18 +7,44 @@ import Designers from '@components/designers'; | |
| import SearchBox from '@components/UI/search-box/index'; | ||
| import styles from '@components/home/home.module.scss'; | ||
| import { userContext } from '@store/user/user-context'; | ||
| import { useState } from 'react'; | ||
| import { membersContext } from '@store/members/members-context'; | ||
| import { searchMemberContext } from '@store/search-members/searchMembers-context'; | ||
| import { searchMembers } from '@helper-functions/search-members'; | ||
| import { useState, useEffect } from 'react'; | ||
| import { Waypoint } from 'react-waypoint'; | ||
|
|
||
| import { | ||
| BRAND_NAME, | ||
| MEMBERS_TITLE, | ||
| NEW_MEMBERS_TITLE, | ||
| NEW_MEMBERS_TO_SHOW, | ||
| } from '@constants/AppConstants'; | ||
|
|
||
| const Home = () => { | ||
| const { showMemberRoleUpdateModal, isSuperUserMode } = userContext(); | ||
| const { | ||
| state: { newMembers: newMembersList }, | ||
| } = membersContext(); | ||
| const { searchTerm } = searchMemberContext(); | ||
| const filterMembersList = searchMembers(newMembersList, searchTerm); | ||
|
|
||
| const { query } = useRouter() || { query: { dev: false } }; | ||
| const { dev } = query; | ||
| const [isOptionKey, setIsOptionKey] = useState(false); | ||
| const [newMembers, setNewMembers] = useState([]); | ||
| const [scrollCount, setScrollCount] = useState(0); | ||
|
|
||
| const fetchNewMembers = () => { | ||
| const newMemberArr = searchTerm ? filterMembersList : newMembersList; | ||
| const noOfMembersToShow = scrollCount * NEW_MEMBERS_TO_SHOW; | ||
| const slicedNewMembersList = newMemberArr.slice(0, noOfMembersToShow); | ||
| setNewMembers(slicedNewMembersList); | ||
| setScrollCount(scrollCount + 1); | ||
| }; | ||
|
|
||
| useEffect(() => { | ||
| fetchNewMembers(); | ||
| }, [newMembersList]); | ||
|
Comment on lines
+45
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can add the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please tell me why we need to provide this function in the dependency array?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the hook is dependent on the function, I thought we can add it. what do you think @sumitd94 @swarajpure ? |
||
|
|
||
| return ( | ||
| <div | ||
|
|
@@ -46,7 +72,8 @@ const Home = () => { | |
| )} | ||
| <Members isOptionKey={isOptionKey} /> | ||
| <h1 className={styles.heading}>{NEW_MEMBERS_TITLE}</h1> | ||
| <NewMembers isOptionKey={isOptionKey} /> | ||
| <NewMembers newMembers={newMembers} isOptionKey={isOptionKey} /> | ||
| {newMembers && <Waypoint onEnter={fetchNewMembers} />} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this scroll count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this count to update the array of new members to show after every scroll and we are using it inside
fetchNewMembersfunction.