Load all contracts, and filter to 99 client-side.
This commit is contained in:
		
							parent
							
								
									a9e1cbc0be
								
							
						
					
					
						commit
						a5e4411075
					
				|  | @ -110,6 +110,8 @@ function ContractsGrid(props: { contracts: Contract[] }) { | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const MAX_CONTRACTS_DISPLAYED = 99 | ||||||
|  | 
 | ||||||
| type Sort = 'createdTime' | 'pool' | 'resolved' | 'all' | type Sort = 'createdTime' | 'pool' | 'resolved' | 'all' | ||||||
| export function SearchableGrid(props: { | export function SearchableGrid(props: { | ||||||
|   contracts: Contract[] |   contracts: Contract[] | ||||||
|  | @ -143,6 +145,9 @@ export function SearchableGrid(props: { | ||||||
|     ) |     ) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   if (matches.length > MAX_CONTRACTS_DISPLAYED) | ||||||
|  |     matches = _.slice(matches, 0, MAX_CONTRACTS_DISPLAYED) | ||||||
|  | 
 | ||||||
|   return ( |   return ( | ||||||
|     <div> |     <div> | ||||||
|       {/* Show a search input next to a sort dropdown */} |       {/* Show a search input next to a sort dropdown */} | ||||||
|  |  | ||||||
|  | @ -107,7 +107,7 @@ export async function listContracts(creatorId: string): Promise<Contract[]> { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function listAllContracts(): Promise<Contract[]> { | export async function listAllContracts(): Promise<Contract[]> { | ||||||
|   const q = query(contractCollection, orderBy('createdTime', 'desc'), limit(99)) |   const q = query(contractCollection, orderBy('createdTime', 'desc')) | ||||||
|   const snapshot = await getDocs(q) |   const snapshot = await getDocs(q) | ||||||
|   return snapshot.docs.map((doc) => doc.data() as Contract) |   return snapshot.docs.map((doc) => doc.data() as Contract) | ||||||
| } | } | ||||||
|  | @ -115,7 +115,7 @@ export async function listAllContracts(): Promise<Contract[]> { | ||||||
| export function listenForContracts( | export function listenForContracts( | ||||||
|   setContracts: (contracts: Contract[]) => void |   setContracts: (contracts: Contract[]) => void | ||||||
| ) { | ) { | ||||||
|   const q = query(contractCollection, orderBy('createdTime', 'desc'), limit(99)) |   const q = query(contractCollection, orderBy('createdTime', 'desc')) | ||||||
|   return onSnapshot(q, (snap) => { |   return onSnapshot(q, (snap) => { | ||||||
|     setContracts(snap.docs.map((doc) => doc.data() as Contract)) |     setContracts(snap.docs.map((doc) => doc.data() as Contract)) | ||||||
|   }) |   }) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user