From ac952f1164eda50459d5489a0a1cb2da12573e39 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 20 Sep 2022 15:49:46 -0500 Subject: [PATCH 1/8] Revert "Don't send creator guide email & interesting markets on create user" This reverts commit a4399aaee9a9a5bd79a2ce1add53a3ea991895fd. --- functions/src/on-create-user.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/functions/src/on-create-user.ts b/functions/src/on-create-user.ts index f23d2f5b..844f75fc 100644 --- a/functions/src/on-create-user.ts +++ b/functions/src/on-create-user.ts @@ -4,8 +4,14 @@ import * as utc from 'dayjs/plugin/utc' dayjs.extend(utc) import { getPrivateUser } from './utils' -import { User } from '../../common/user' -import { sendPersonalFollowupEmail, sendWelcomeEmail } from './emails' +import { User } from 'common/user' +import { + sendCreatorGuideEmail, + sendInterestingMarketsEmail, + sendPersonalFollowupEmail, + sendWelcomeEmail, +} from './emails' +import { getTrendingContracts } from './weekly-markets-emails' export const onCreateUser = functions .runWith({ secrets: ['MAILGUN_KEY'] }) @@ -17,6 +23,23 @@ export const onCreateUser = functions await sendWelcomeEmail(user, privateUser) + const guideSendTime = dayjs().add(28, 'hours').toString() + await sendCreatorGuideEmail(user, privateUser, guideSendTime) + const followupSendTime = dayjs().add(48, 'hours').toString() await sendPersonalFollowupEmail(user, privateUser, followupSendTime) + + // skip email if weekly email is about to go out + const day = dayjs().utc().day() + if (day === 0 || (day === 1 && dayjs().utc().hour() <= 19)) return + + const contracts = await getTrendingContracts() + const marketsSendTime = dayjs().add(24, 'hours').toString() + + await sendInterestingMarketsEmail( + user, + privateUser, + contracts, + marketsSendTime + ) }) From 8920241c39af6f1d65513288619b5e58e28b451c Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 20 Sep 2022 15:56:28 -0500 Subject: [PATCH 2/8] space out onboarding emails --- functions/src/on-create-user.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/functions/src/on-create-user.ts b/functions/src/on-create-user.ts index 844f75fc..03c6dda0 100644 --- a/functions/src/on-create-user.ts +++ b/functions/src/on-create-user.ts @@ -23,15 +23,21 @@ export const onCreateUser = functions await sendWelcomeEmail(user, privateUser) - const guideSendTime = dayjs().add(28, 'hours').toString() - await sendCreatorGuideEmail(user, privateUser, guideSendTime) - const followupSendTime = dayjs().add(48, 'hours').toString() await sendPersonalFollowupEmail(user, privateUser, followupSendTime) - // skip email if weekly email is about to go out const day = dayjs().utc().day() - if (day === 0 || (day === 1 && dayjs().utc().hour() <= 19)) return + + const skipInterestingMarkets = + // skip email if weekly email is about to go out + day === 0 || (day === 1 && dayjs().utc().hour() <= 19) + + const guideSendTime = dayjs() + .add(skipInterestingMarkets ? 24 : 96, 'hours') + .toString() + await sendCreatorGuideEmail(user, privateUser, guideSendTime) + + if (skipInterestingMarkets) return const contracts = await getTrendingContracts() const marketsSendTime = dayjs().add(24, 'hours').toString() From 379e736e514d4e5967974bb611c5e5b5c85463c9 Mon Sep 17 00:00:00 2001 From: mantikoros <95266179+mantikoros@users.noreply.github.com> Date: Tue, 20 Sep 2022 15:57:27 -0500 Subject: [PATCH 3/8] hide liquidity panel (#904) --- web/components/liquidity-panel.tsx | 39 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/web/components/liquidity-panel.tsx b/web/components/liquidity-panel.tsx index 58f57a8a..7e216be5 100644 --- a/web/components/liquidity-panel.tsx +++ b/web/components/liquidity-panel.tsx @@ -14,6 +14,8 @@ import { Col } from './layout/col' import { track } from 'web/lib/service/analytics' import { InfoTooltip } from './info-tooltip' import { BETTORS, PRESENT_BET } from 'common/user' +import { buildArray } from 'common/util/array' +import { useAdmin } from 'web/hooks/use-admin' export function LiquidityPanel(props: { contract: CPMMContract }) { const { contract } = props @@ -28,31 +30,32 @@ export function LiquidityPanel(props: { contract: CPMMContract }) { setShowWithdrawal(true) }, [showWithdrawal, lpShares]) + const isCreator = user?.id === contract.creatorId + const isAdmin = useAdmin() + + if (!showWithdrawal && !isAdmin && !isCreator) return <> + return ( , }, - ...(showWithdrawal - ? [ - { - title: 'Withdraw', - content: ( - - ), - }, - ] - : []), + showWithdrawal && { + title: 'Withdraw', + content: ( + + ), + }, { title: 'Pool', content: , - }, - ]} + } + )} /> ) } From 106dc232b8fb25a776dc897b757a15ba6abaa769 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 20 Sep 2022 16:03:09 -0500 Subject: [PATCH 4/8] send market guide onboarding email after 96 hrs --- functions/src/on-create-user.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/functions/src/on-create-user.ts b/functions/src/on-create-user.ts index 03c6dda0..71425f2c 100644 --- a/functions/src/on-create-user.ts +++ b/functions/src/on-create-user.ts @@ -26,18 +26,12 @@ export const onCreateUser = functions const followupSendTime = dayjs().add(48, 'hours').toString() await sendPersonalFollowupEmail(user, privateUser, followupSendTime) - const day = dayjs().utc().day() - - const skipInterestingMarkets = - // skip email if weekly email is about to go out - day === 0 || (day === 1 && dayjs().utc().hour() <= 19) - - const guideSendTime = dayjs() - .add(skipInterestingMarkets ? 24 : 96, 'hours') - .toString() + const guideSendTime = dayjs().add(96, 'hours').toString() await sendCreatorGuideEmail(user, privateUser, guideSendTime) - if (skipInterestingMarkets) return + // skip email if weekly email is about to go out + const day = dayjs().utc().day() + if (day === 0 || (day === 1 && dayjs().utc().hour() <= 19)) return const contracts = await getTrendingContracts() const marketsSendTime = dayjs().add(24, 'hours').toString() From a2d9e8e3d27ec7a90853ce530cc0642817636376 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 20 Sep 2022 14:03:33 -0700 Subject: [PATCH 5/8] Cleanup free answer comment stuff (#897) * Remove unused most-recent-bet-time stuff * Remove strange reply box hiding behavior * Tidying markup --- .../feed/feed-answer-comment-group.tsx | 50 +++---------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/web/components/feed/feed-answer-comment-group.tsx b/web/components/feed/feed-answer-comment-group.tsx index 958b6d6d..47cb9743 100644 --- a/web/components/feed/feed-answer-comment-group.tsx +++ b/web/components/feed/feed-answer-comment-group.tsx @@ -11,7 +11,6 @@ import clsx from 'clsx' import { ContractCommentInput, FeedComment, - getMostRecentCommentableBet, } from 'web/components/feed/feed-comments' import { CopyLinkDateTimeComponent } from 'web/components/feed/copy-link-date-time' import { useRouter } from 'next/router' @@ -50,27 +49,6 @@ export function FeedAnswerCommentGroup(props: { const answerElementId = `answer-${answer.id}` const commentsByCurrentUser = (user && commentsByUserId[user.id]) ?? [] const isFreeResponseContractPage = !!commentsByCurrentUser - const mostRecentCommentableBet = getMostRecentCommentableBet( - betsByCurrentUser, - commentsByCurrentUser, - user, - answer.number.toString() - ) - const [usersMostRecentBetTimeAtLoad, setUsersMostRecentBetTimeAtLoad] = - useState( - !user ? undefined : mostRecentCommentableBet?.createdTime ?? 0 - ) - - useEffect(() => { - if (user && usersMostRecentBetTimeAtLoad === undefined) - setUsersMostRecentBetTimeAtLoad( - mostRecentCommentableBet?.createdTime ?? 0 - ) - }, [ - mostRecentCommentableBet?.createdTime, - user, - usersMostRecentBetTimeAtLoad, - ]) const scrollAndOpenReplyInput = useEvent( (comment?: ContractComment, answer?: Answer) => { @@ -85,19 +63,6 @@ export function FeedAnswerCommentGroup(props: { } ) - useEffect(() => { - // Only show one comment input for a bet at a time - if ( - betsByCurrentUser.length > 1 && - // inputRef?.textContent?.length === 0 && //TODO: editor.isEmpty - betsByCurrentUser.sort((a, b) => b.createdTime - a.createdTime)[0] - ?.outcome !== answer.number.toString() - ) - setShowReply(false) - // Even if we pass memoized bets this still runs on every render, which we don't want - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [betsByCurrentUser.length, user, answer.number]) - useEffect(() => { if (router.asPath.endsWith(`#${answerElementId}`)) { setHighlighted(true) @@ -105,10 +70,7 @@ export function FeedAnswerCommentGroup(props: { }, [answerElementId, router.asPath]) return ( - + {isFreeResponseContractPage && ( -
+