Denormalize the avatar URL on contract creation (#29)
This commit is contained in:
		
							parent
							
								
									279437ba08
								
							
						
					
					
						commit
						7d7286b1c1
					
				|  | @ -5,6 +5,7 @@ export type Contract = { | ||||||
|   creatorId: string |   creatorId: string | ||||||
|   creatorName: string |   creatorName: string | ||||||
|   creatorUsername: string |   creatorUsername: string | ||||||
|  |   creatorAvatarUrl?: string // Start requiring after Mar 01, 2022
 | ||||||
| 
 | 
 | ||||||
|   question: string |   question: string | ||||||
|   description: string // More info about what the contract is about
 |   description: string // More info about what the contract is about
 | ||||||
|  |  | ||||||
|  | @ -24,6 +24,7 @@ export function getNewContract( | ||||||
|     creatorId: creator.id, |     creatorId: creator.id, | ||||||
|     creatorName: creator.name, |     creatorName: creator.name, | ||||||
|     creatorUsername: creator.username, |     creatorUsername: creator.username, | ||||||
|  |     creatorAvatarUrl: creator.avatarUrl, | ||||||
| 
 | 
 | ||||||
|     question: question.trim(), |     question: question.trim(), | ||||||
|     description: description.trim(), |     description: description.trim(), | ||||||
|  |  | ||||||
|  | @ -69,14 +69,6 @@ export async function updateContract( | ||||||
|   await updateDoc(docRef, update) |   await updateDoc(docRef, update) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export async function pushNewContract(contract: Omit<Contract, 'id'>) { |  | ||||||
|   const newContractRef = doc(contractCollection) |  | ||||||
|   const fullContract: Contract = { ...contract, id: newContractRef.id } |  | ||||||
| 
 |  | ||||||
|   await setDoc(newContractRef, fullContract) |  | ||||||
|   return fullContract |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export async function getContractFromId(contractId: string) { | export async function getContractFromId(contractId: string) { | ||||||
|   const docRef = doc(db, 'contracts', contractId) |   const docRef = doc(db, 'contracts', contractId) | ||||||
|   const result = await getDoc(docRef) |   const result = await getDoc(docRef) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user