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) {
|
export async function listAllComments(contractId: string) {
|
||||||
const comments = await getValues<Comment>(getCommentsCollection(contractId))
|
return await getValues<Comment>(
|
||||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
query(getCommentsCollection(contractId), orderBy('createdTime', 'desc'))
|
||||||
return comments
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function listAllCommentsOnGroup(groupId: string) {
|
export async function listAllCommentsOnGroup(groupId: string) {
|
||||||
const comments = await getValues<GroupComment>(
|
return await getValues<GroupComment>(
|
||||||
getCommentsOnGroupCollection(groupId)
|
query(getCommentsOnGroupCollection(groupId), orderBy('createdTime', 'desc'))
|
||||||
)
|
)
|
||||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
|
||||||
return comments
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listenForCommentsOnContract(
|
export function listenForCommentsOnContract(
|
||||||
|
@ -110,23 +108,21 @@ export function listenForCommentsOnContract(
|
||||||
setComments: (comments: ContractComment[]) => void
|
setComments: (comments: ContractComment[]) => void
|
||||||
) {
|
) {
|
||||||
return listenForValues<ContractComment>(
|
return listenForValues<ContractComment>(
|
||||||
getCommentsCollection(contractId),
|
query(getCommentsCollection(contractId), orderBy('createdTime', 'desc')),
|
||||||
(comments) => {
|
setComments
|
||||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
|
||||||
setComments(comments)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function listenForCommentsOnGroup(
|
export function listenForCommentsOnGroup(
|
||||||
groupId: string,
|
groupId: string,
|
||||||
setComments: (comments: GroupComment[]) => void
|
setComments: (comments: GroupComment[]) => void
|
||||||
) {
|
) {
|
||||||
return listenForValues<GroupComment>(
|
return listenForValues<GroupComment>(
|
||||||
|
query(
|
||||||
getCommentsOnGroupCollection(groupId),
|
getCommentsOnGroupCollection(groupId),
|
||||||
(comments) => {
|
orderBy('createdTime', 'desc')
|
||||||
comments.sort((c1, c2) => c1.createdTime - c2.createdTime)
|
),
|
||||||
setComments(comments)
|
setComments
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,9 +168,6 @@ export function ContractPageContent(
|
||||||
[bets]
|
[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 tips = useTipTxns({ contractId: contract.id })
|
||||||
|
|
||||||
const [showConfetti, setShowConfetti] = useState(false)
|
const [showConfetti, setShowConfetti] = useState(false)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user