mirror of
				https://github.com/Telecominfraproject/wlan-cloud-ui.git
				synced 2025-11-02 19:57:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			31 lines
		
	
	
		
			816 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			816 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
export const updateQueryGetAllProfiles = (previousResult, { fetchMoreResult }) => {
 | 
						|
  const previousEntry = previousResult.getAllProfiles;
 | 
						|
  const newItems = fetchMoreResult.getAllProfiles.items;
 | 
						|
 | 
						|
  return {
 | 
						|
    getAllProfiles: {
 | 
						|
      context: { ...fetchMoreResult.getAllProfiles.context },
 | 
						|
      items: [...previousEntry.items, ...newItems],
 | 
						|
      __typename: previousEntry.__typename,
 | 
						|
    },
 | 
						|
  };
 | 
						|
};
 | 
						|
 | 
						|
export const fetchMoreProfiles = (e, profile, fetchMore) => {
 | 
						|
  if (profile.getAllProfiles.context.lastPage) {
 | 
						|
    return false;
 | 
						|
  }
 | 
						|
 | 
						|
  e.persist();
 | 
						|
  const { target } = e;
 | 
						|
 | 
						|
  if (target.scrollTop + target.offsetHeight + 10 >= target.scrollHeight) {
 | 
						|
    fetchMore({
 | 
						|
      variables: { context: { ...profile.getAllProfiles.context } },
 | 
						|
      updateQuery: updateQueryGetAllProfiles,
 | 
						|
    });
 | 
						|
  }
 | 
						|
 | 
						|
  return true;
 | 
						|
};
 |