Denormalize the avatar URL on contract creation (#29)

This commit is contained in:
Austin Chen 2022-01-16 01:03:59 -05:00 committed by GitHub
parent 279437ba08
commit 7d7286b1c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 8 deletions

View File

@ -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

View File

@ -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(),

View File

@ -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)