diff --git a/functions/src/on-update-contract.ts b/functions/src/on-update-contract.ts index b077ea92..8b16b3d6 100644 --- a/functions/src/on-update-contract.ts +++ b/functions/src/on-update-contract.ts @@ -14,13 +14,25 @@ export const onUpdateContract = functions.firestore const previousValue = change.before.data() as Contract if (previousValue.isResolved !== contract.isResolved) { + let resolutionText = contract.resolution ?? contract.question + if (contract.outcomeType === 'FREE_RESPONSE') { + const answerText = contract.answers.find( + (answer) => answer.id === contract.resolution + )?.text + if (answerText) resolutionText = answerText + } else if (contract.outcomeType === 'BINARY') { + if (resolutionText === 'MKT' && contract.resolutionProbability) + resolutionText = `${contract.resolutionProbability}%` + else if (resolutionText === 'MKT') resolutionText = 'PROB' + } + await createNotification( contract.id, 'contract', 'resolved', contractUpdater, eventId, - contract.resolution ?? contract.question, + resolutionText, contract ) } else if ( diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 52d5d1d6..0b569d03 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -30,8 +30,12 @@ import { UsersIcon } from '@heroicons/react/solid' import { RelativeTimestamp } from 'web/components/relative-timestamp' import { Linkify } from 'web/components/linkify' import { + BinaryOutcomeLabel, + CancelLabel, FreeResponseOutcomeLabel, + MultiLabel, OutcomeLabel, + ProbPercentLabel, } from 'web/components/outcome-label' import { groupNotifications, @@ -746,26 +750,39 @@ function NotificationTextLabel(props: { sourceType, sourceUpdateType, contract - ) && - contract?.resolution + ) ) { - if (contract.outcomeType === 'FREE_RESPONSE') { + if (sourceText) { + if (sourceText === 'YES' || sourceText == 'NO') { + return + } + if (sourceText.includes('%')) + return ( + + ) + if (sourceText === 'CANCEL') return + if (sourceText === 'MKT' || sourceText === 'PROB') return + // Show free response answer text + return {sourceText} + } else if (contract?.resolution) { + if (contract.outcomeType === 'FREE_RESPONSE') { + return ( + + ) + } return ( - ) - } - return ( - - ) + } else return
} else if (sourceType === 'contract') { return (