From 7e44af318b404088cefa55d9fa241a38120e6011 Mon Sep 17 00:00:00 2001
From: Austin Chen
Date: Fri, 21 Jan 2022 12:53:51 -0600
Subject: [PATCH] Truncate both question and comments in activity feed
---
web/components/contract-feed.tsx | 74 +++++++++++++++++++++-----------
1 file changed, 49 insertions(+), 25 deletions(-)
diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx
index 02b58bca..07d2e578 100644
--- a/web/components/contract-feed.tsx
+++ b/web/components/contract-feed.tsx
@@ -53,8 +53,12 @@ export function AvatarWithIcon(props: { username: string; avatarUrl: string }) {
)
}
-function FeedComment(props: { activityItem: any }) {
- const { activityItem } = props
+function FeedComment(props: {
+ activityItem: any
+ moreHref: string
+ feedType: 'activity' | 'market'
+}) {
+ const { activityItem, moreHref, feedType } = props
const { person, text, amount, outcome, createdTime } = activityItem
const bought = amount >= 0 ? 'bought' : 'sold'
@@ -75,11 +79,11 @@ function FeedComment(props: { activityItem: any }) {
-
+
>
)
@@ -222,21 +226,40 @@ export function ContractDescription(props: {
)
}
+function TruncatedComment(props: {
+ comment: string
+ moreHref: string
+ shouldTruncate?: boolean
+}) {
+ const { comment, moreHref, shouldTruncate } = props
+ let truncated = comment
+
+ // Keep descriptions to at most 400 characters
+ if (shouldTruncate && truncated.length > 400) {
+ truncated = truncated.slice(0, 400)
+ // Make sure to end on a space
+ const i = truncated.lastIndexOf(' ')
+ truncated = truncated.slice(0, i)
+ }
+
+ return (
+
+
+ {truncated != comment && (
+
+ ... (show more)
+
+ )}
+
+ )
+}
+
function FeedQuestion(props: { contract: Contract }) {
const { contract } = props
const { creatorName, creatorUsername, createdTime, question, resolution } =
contract
const { probPercent } = contractMetrics(contract)
- let description = contract.description
- // Keep descriptions to at most 400 characters
- if (description.length > 400) {
- description = description.slice(0, 400)
- // Make sure to end on a space
- const i = description.lastIndexOf(' ')
- description = description.slice(0, i)
- }
-
// Currently hidden on mobile; ideally we'd fit this in somewhere.
const closeMessage =
contract.isResolved || !contract.closeTime ? null : (
@@ -284,14 +307,11 @@ function FeedQuestion(props: { contract: Contract }) {
probPercent={probPercent}
/>
-
-
- {description != contract.description && (
-
- ... (show more)
-
- )}
-
+
>
)
@@ -597,7 +617,11 @@ export function ContractFeed(props: {
)
) : activityItem.type === 'comment' ? (
-
+
) : activityItem.type === 'bet' ? (
) : activityItem.type === 'betgroup' ? (