Fix notification for updated questions (#782)

* Fix update notification for question, description

* Don't notify on updated description
This commit is contained in:
Sinclair Chen 2022-08-22 15:26:54 -07:00 committed by GitHub
parent b9a667b126
commit ec4d0f6b4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,19 +40,16 @@ export const onUpdateContract = functions.firestore
) )
} else if ( } else if (
previousValue.closeTime !== contract.closeTime || previousValue.closeTime !== contract.closeTime ||
previousValue.description !== contract.description previousValue.question !== contract.question
) { ) {
let sourceText = '' let sourceText = ''
if (previousValue.closeTime !== contract.closeTime && contract.closeTime) if (
previousValue.closeTime !== contract.closeTime &&
contract.closeTime
) {
sourceText = contract.closeTime.toString() sourceText = contract.closeTime.toString()
else { } else if (previousValue.question !== contract.question) {
const oldTrimmedDescription = previousValue.description.trim() sourceText = contract.question
const newTrimmedDescription = contract.description.trim()
if (oldTrimmedDescription === '') sourceText = newTrimmedDescription
else
sourceText = newTrimmedDescription
.split(oldTrimmedDescription)[1]
.trim()
} }
await createNotification( await createNotification(