Order comments in Firestore instead of on client
This commit is contained in:
parent
5b6db12720
commit
708ea9555c
|
@ -92,17 +92,15 @@ function getCommentsOnGroupCollection(groupId: string) {
|
|||
}
|
||||
|
||||
export async function listAllComments(contractId: string) {
|
||||
const comments = await getValues<Comment>(getCommentsCollection(contractId))
|
||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||
return comments
|
||||
return await getValues<Comment>(
|
||||
query(getCommentsCollection(contractId), orderBy('createdTime', 'desc'))
|
||||
)
|
||||
}
|
||||
|
||||
export async function listAllCommentsOnGroup(groupId: string) {
|
||||
const comments = await getValues<GroupComment>(
|
||||
getCommentsOnGroupCollection(groupId)
|
||||
return await getValues<GroupComment>(
|
||||
query(getCommentsOnGroupCollection(groupId), orderBy('createdTime', 'desc'))
|
||||
)
|
||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||
return comments
|
||||
}
|
||||
|
||||
export function listenForCommentsOnContract(
|
||||
|
@ -110,23 +108,21 @@ export function listenForCommentsOnContract(
|
|||
setComments: (comments: ContractComment[]) => void
|
||||
) {
|
||||
return listenForValues<ContractComment>(
|
||||
getCommentsCollection(contractId),
|
||||
(comments) => {
|
||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||
setComments(comments)
|
||||
}
|
||||
query(getCommentsCollection(contractId), orderBy('createdTime', 'desc')),
|
||||
setComments
|
||||
)
|
||||
}
|
||||
|
||||
export function listenForCommentsOnGroup(
|
||||
groupId: string,
|
||||
setComments: (comments: GroupComment[]) => void
|
||||
) {
|
||||
return listenForValues<GroupComment>(
|
||||
query(
|
||||
getCommentsOnGroupCollection(groupId),
|
||||
(comments) => {
|
||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||
setComments(comments)
|
||||
}
|
||||
orderBy('createdTime', 'desc')
|
||||
),
|
||||
setComments
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -168,9 +168,6 @@ export function ContractPageContent(
|
|||
[bets]
|
||||
)
|
||||
|
||||
// Sort for now to see if bug is fixed.
|
||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
||||
|
||||
const tips = useTipTxns({ contractId: contract.id })
|
||||
|
||||
const [showConfetti, setShowConfetti] = useState(false)
|
||||
|
|
Loading…
Reference in New Issue
Block a user