From 3cf4cb7a778aa980db3ddc7a6719e2b5ec2fc101 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 16:54:08 -0600 Subject: [PATCH 1/7] Show custom feed of contracts from folds your follow or have bet on. --- common/util/array.ts | 3 + firestore.rules | 4 + web/components/bets-list.tsx | 6 +- web/hooks/use-user-bets.ts | 6 +- web/lib/firebase/folds.ts | 18 ++++- web/pages/activity.tsx | 2 +- web/pages/home.tsx | 143 ++++++++++++++++++++++++----------- 7 files changed, 130 insertions(+), 52 deletions(-) create mode 100644 common/util/array.ts diff --git a/common/util/array.ts b/common/util/array.ts new file mode 100644 index 00000000..fba342aa --- /dev/null +++ b/common/util/array.ts @@ -0,0 +1,3 @@ +export function filterDefined(array: (T | null | undefined)[]) { + return array.filter((item) => item) as T[] +} diff --git a/firestore.rules b/firestore.rules index 18572047..73eafb24 100644 --- a/firestore.rules +++ b/firestore.rules @@ -52,5 +52,9 @@ service cloud.firestore { allow read; allow write: if request.auth.uid == userId; } + + match /{somePath=**}/followers/{userId} { + allow read; + } } } \ No newline at end of file diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index 5af4bb0d..6cff5c8b 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -32,12 +32,12 @@ import { OutcomeLabel, YesLabel, NoLabel, MarketLabel } from './outcome-label' export function BetsList(props: { user: User }) { const { user } = props - const bets = useUserBets(user?.id ?? '') + const bets = useUserBets(user.id) const [contracts, setContracts] = useState([]) useEffect(() => { - const loadedBets = bets === 'loading' ? [] : bets + const loadedBets = bets ? bets : [] const contractIds = _.uniq(loadedBets.map((bet) => bet.contractId)) let disposed = false @@ -52,7 +52,7 @@ export function BetsList(props: { user: User }) { } }, [bets]) - if (bets === 'loading') { + if (!bets) { return <> } diff --git a/web/hooks/use-user-bets.ts b/web/hooks/use-user-bets.ts index e52d3786..6af56902 100644 --- a/web/hooks/use-user-bets.ts +++ b/web/hooks/use-user-bets.ts @@ -1,11 +1,11 @@ import { useEffect, useState } from 'react' import { Bet, listenForUserBets } from '../lib/firebase/bets' -export const useUserBets = (userId: string) => { - const [bets, setBets] = useState('loading') +export const useUserBets = (userId: string | undefined) => { + const [bets, setBets] = useState(undefined) useEffect(() => { - return listenForUserBets(userId, setBets) + if (userId) return listenForUserBets(userId, setBets) }, [userId]) return bets diff --git a/web/lib/firebase/folds.ts b/web/lib/firebase/folds.ts index 8ff9a385..58618414 100644 --- a/web/lib/firebase/folds.ts +++ b/web/lib/firebase/folds.ts @@ -1,7 +1,9 @@ import { collection, + collectionGroup, deleteDoc, doc, + getDocs, query, setDoc, updateDoc, @@ -12,7 +14,7 @@ import { Fold } from '../../../common/fold' import { Contract, contractCollection } from './contracts' import { db } from './init' import { User } from './users' -import { getValues, listenForValue, listenForValues } from './utils' +import { getValue, getValues, listenForValue, listenForValues } from './utils' const foldCollection = collection(db, 'folds') @@ -39,6 +41,10 @@ export function listenForFolds(setFolds: (folds: Fold[]) => void) { return listenForValues(foldCollection, setFolds) } +export function getFold(foldId: string) { + return getValue(doc(foldCollection, foldId)) +} + export async function getFoldBySlug(slug: string) { const q = query(foldCollection, where('slug', '==', slug)) const folds = await getValues(q) @@ -147,3 +153,13 @@ export async function getFoldsByTags(tags: string[]) { return _.sortBy(folds, (fold) => -1 * fold.followCount) } + +export async function getFollowedFolds(userId: string) { + const snapshot = await getDocs( + query(collectionGroup(db, 'followers'), where('userId', '==', userId)) + ) + const foldIds = snapshot.docs.map( + (doc) => doc.ref.parent.parent?.id as string + ) + return foldIds +} diff --git a/web/pages/activity.tsx b/web/pages/activity.tsx index b740d580..be5a9809 100644 --- a/web/pages/activity.tsx +++ b/web/pages/activity.tsx @@ -100,7 +100,7 @@ export function ActivityFeed(props: {
diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 840e1746..61d785e4 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -1,70 +1,123 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import Router from 'next/router' import _ from 'lodash' import { Contract, listAllContracts } from '../lib/firebase/contracts' import { Page } from '../components/page' import { ActivityFeed, findActiveContracts } from './activity' -import { - getRecentComments, - Comment, - listAllComments, -} from '../lib/firebase/comments' -import { Bet, getRecentBets, listAllBets } from '../lib/firebase/bets' +import { Comment, listAllComments } from '../lib/firebase/comments' +import { Bet, listAllBets } from '../lib/firebase/bets' import FeedCreate from '../components/feed-create' import { Spacer } from '../components/layout/spacer' import { Col } from '../components/layout/col' import { useUser } from '../hooks/use-user' import { useContracts } from '../hooks/use-contracts' +import { getFollowedFolds, listAllFolds } from '../lib/firebase/folds' +import { Fold } from '../../common/fold' +import { filterDefined } from '../../common/util/array' +import { useUserBets } from '../hooks/use-user-bets' export async function getStaticProps() { - const [contracts, recentComments, recentBets] = await Promise.all([ + const [contracts, folds] = await Promise.all([ listAllContracts().catch((_) => []), - getRecentComments().catch(() => []), - getRecentBets().catch(() => []), + listAllFolds().catch(() => []), ]) - const activeContracts = findActiveContracts( - contracts, - recentComments, - recentBets - ) - const activeContractBets = await Promise.all( - activeContracts.map((contract) => listAllBets(contract.id).catch((_) => [])) - ) - const activeContractComments = await Promise.all( - activeContracts.map((contract) => - listAllComments(contract.id).catch((_) => []) - ) - ) - return { props: { - activeContracts, - activeContractBets, - activeContractComments, + contracts, + folds, }, revalidate: 60, // regenerate after a minute } } -const Home = (props: { - activeContracts: Contract[] - activeContractBets: Bet[][] - activeContractComments: Comment[][] -}) => { - const { activeContracts, activeContractBets, activeContractComments } = props +const Home = (props: { contracts: Contract[]; folds: Fold[] }) => { + const { folds } = props const user = useUser() - const contracts = useContracts() ?? activeContracts - const contractsMap = _.fromPairs( - contracts.map((contract) => [contract.id, contract]) + const contracts = useContracts() ?? props.contracts + + const [followedFoldIds, setFollowedFoldIds] = useState( + undefined ) - const updatedContracts = activeContracts.map( - (contract) => contractsMap[contract.id] + + useEffect(() => { + if (user) { + getFollowedFolds(user.id).then((foldIds) => setFollowedFoldIds(foldIds)) + } + }, [user]) + + const followedFolds = filterDefined( + (followedFoldIds ?? []).map((id) => folds.find((fold) => fold.id === id)) ) + const tagSet = new Set( + _.flatten(followedFolds.map((fold) => fold.lowercaseTags)) + ) + + const yourBets = useUserBets(user?.id) + const yourBetContracts = new Set( + (yourBets ?? []).map((bet) => bet.contractId) + ) + + const feedContracts = + followedFoldIds && yourBets + ? contracts.filter( + (contract) => + contract.lowercaseTags.some((tag) => tagSet.has(tag)) || + yourBetContracts.has(contract.id) + ) + : undefined + + const feedContractsKey = feedContracts?.map(({ id }) => id).join(',') + + const [feedBets, setFeedBets] = useState() + const [feedComments, setFeedComments] = useState() + + useEffect(() => { + if (feedContracts) { + Promise.all( + feedContracts.map((contract) => listAllBets(contract.id)) + ).then(setFeedBets) + Promise.all( + feedContracts.map((contract) => listAllComments(contract.id)) + ).then(setFeedComments) + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [feedContractsKey]) + + const oneDayMS = 24 * 60 * 60 * 1000 + const recentBets = + feedBets && + feedBets.flat().filter((bet) => bet.createdTime > Date.now() - oneDayMS) + + const activeContracts = + feedContracts && + feedComments && + recentBets && + findActiveContracts(feedContracts, feedComments.flat(), recentBets, 365) + + const contractBets = activeContracts + ? activeContracts.map( + (contract) => feedBets[feedContracts.indexOf(contract)] + ) + : [] + const contractComments = activeContracts + ? activeContracts.map( + (contract) => feedComments[feedContracts.indexOf(contract)] + ) + : [] + + console.log({ + followedFoldIds, + followedFolds, + yourBetContracts, + feedContracts, + feedBets, + feedComments, + }) if (user === null) { Router.replace('/') @@ -74,14 +127,16 @@ const Home = (props: { return ( - + - + {activeContracts ? ( + + ) : null} From 8e06e4351ea4ef69bd88090348ab060315fbb474 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 17:11:38 -0600 Subject: [PATCH 2/7] Add tw-elements UI library --- web/package.json | 3 +- web/pages/_document.tsx | 1 + web/tailwind.config.js | 6 +- yarn.lock | 130 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 132 insertions(+), 8 deletions(-) diff --git a/web/package.json b/web/package.json index 92ca48d3..827030e4 100644 --- a/web/package.json +++ b/web/package.json @@ -27,7 +27,8 @@ "next": "12.0.7", "react": "17.0.2", "react-dom": "17.0.2", - "react-expanding-textarea": "^2.3.4" + "react-expanding-textarea": "^2.3.4", + "tw-elements": "^1.0.0-alpha10" }, "devDependencies": { "@tailwindcss/forms": "0.4.0", diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx index d2ccc8e7..c12afbab 100644 --- a/web/pages/_document.tsx +++ b/web/pages/_document.tsx @@ -31,6 +31,7 @@ export default function Document() { `, }} /> + diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 4319621d..1d2335b4 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -21,7 +21,11 @@ module.exports = { variants: { extend: {}, }, - plugins: [require('@tailwindcss/forms'), require('daisyui')], + plugins: [ + require('@tailwindcss/forms'), + require('daisyui'), + require('tw-elements/dist/plugin'), + ], daisyui: { themes: [ diff --git a/yarn.lock b/yarn.lock index ab0d8142..3efd42f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -865,6 +865,11 @@ resolved "https://registry.yarnpkg.com/@panva/asn1.js/-/asn1.js-1.0.0.tgz#dd55ae7b8129e02049f009408b97c61ccf9032f6" integrity sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw== +"@popperjs/core@^2.6.0": + version "2.11.2" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.2.tgz#830beaec4b4091a9e9398ac50f865ddea52186b9" + integrity sha512-92FRmppjjqz29VMJ2dn+xdyXZBrMlE42AV6Kq6BwjWV7CNUW1hs2FtxSNLQE+gJhaZ6AAmYuO9y8dshhcBl7vA== + "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" @@ -1534,6 +1539,11 @@ boolbase@^1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= +bootstrap@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.1.3.tgz#ba081b0c130f810fa70900acbc1c6d3c28fa8f34" + integrity sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1726,6 +1736,34 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" +chart.js@^2.9.4: + version "2.9.4" + resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.9.4.tgz#0827f9563faffb2dc5c06562f8eb10337d5b9684" + integrity sha512-B07aAzxcrikjAPyV+01j7BmOpxtQETxTSlQ26BEYJ+3iUkbNKaOJ/nDbT6JjyqYxseM0ON12COHYdU2cTIjC7A== + dependencies: + chartjs-color "^2.1.0" + moment "^2.10.2" + +chartjs-color-string@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz#1df096621c0e70720a64f4135ea171d051402f71" + integrity sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A== + dependencies: + color-name "^1.0.0" + +chartjs-color@^2.1.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/chartjs-color/-/chartjs-color-2.4.1.tgz#6118bba202fe1ea79dd7f7c0f9da93467296c3b0" + integrity sha512-haqOg1+Yebys/Ts/9bLo/BqUcONQOdr/hoEr2LLTRl6C5LXctUdHxsCYfvQVg5JIxITrfCNUDr4ntqmQk9+/0w== + dependencies: + chartjs-color-string "^0.6.0" + color-convert "^1.9.3" + +chartjs-plugin-datalabels@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/chartjs-plugin-datalabels/-/chartjs-plugin-datalabels-0.7.0.tgz#f72e44edb2db45ef68913e9320bcc50398a205e6" + integrity sha512-PKVUX14nYhH0wcdCpgOoC39Gbzvn6cZ7O9n+bwc02yKD9FTnJ7/TSrBcfebmolFZp1Rcicr9xbT0a5HUbigS7g== + chokidar@3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" @@ -1741,7 +1779,7 @@ chokidar@3.5.1: optionalDependencies: fsevents "~2.3.1" -chokidar@^3.5.2: +chokidar@^3.5.2, chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -1816,7 +1854,7 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= -color-convert@^1.9.0: +color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -1835,7 +1873,7 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@^1.1.4, color-name@~1.1.4: +color-name@^1.0.0, color-name@^1.1.4, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== @@ -2092,6 +2130,11 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.10.tgz#2ad3a7bed70f35b965707c092e5f30b327c290e5" integrity sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA== +custom-event-polyfill@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/custom-event-polyfill/-/custom-event-polyfill-1.0.7.tgz#9bc993ddda937c1a30ccd335614c6c58c4f87aee" + integrity sha512-TDDkd5DkaZxZFM8p+1I3yAlvM3rSr1wbrOliG4yJiwinMZN8z/iGL7BTlDkrJcYTmgUSb4ywVCc3ZaUtOtC76w== + d3-array@2, d3-array@^2.3.0: version "2.12.1" resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-2.12.1.tgz#e20b41aafcdffdf5d50928004ececf815a465e81" @@ -2251,6 +2294,11 @@ deep-is@^0.1.3, deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +deepmerge@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" + integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== + define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -2300,6 +2348,13 @@ destroy@~1.0.4: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= +detect-autofill@^1.1.3: + version "1.1.4" + resolved "https://registry.yarnpkg.com/detect-autofill/-/detect-autofill-1.1.4.tgz#1424ca5863c69a1e0373ea85a4f0edccc2357479" + integrity sha512-utCBQwCR/beSnADQmBC7C4tTueBBkYCl6WSpfGUkYKO/+MzPxqYGj6G4MvHzcKmH1gCTK+VunX2vaagvkRXPvA== + dependencies: + custom-event-polyfill "^1.0.7" + detective@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b" @@ -2914,7 +2969,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.7, fast-glob@^3.2.9: +fast-glob@^3.2.11, fast-glob@^3.2.7, fast-glob@^3.2.9: version "3.2.11" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== @@ -4308,6 +4363,11 @@ minimist@^1.1.1, minimist@^1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== +moment@^2.10.2: + version "2.29.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" + integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== + mri@^1.1.5: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" @@ -4804,6 +4864,11 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +perfect-scrollbar@^1.5.0: + version "1.5.5" + resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-1.5.5.tgz#41a211a2fb52a7191eff301432134ea47052b27f" + integrity sha512-dzalfutyP3e/FOpdlhVryN4AJ5XDVauVWxybSkLZmakFE2sS3y3pc4JnSprw8tGmHvkaG5Edr5T7LBTZ+WWU2g== + performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" @@ -4836,6 +4901,11 @@ platform@1.3.6: resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7" integrity sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg== +popper.js@^1.16.1: + version "1.16.1" + resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b" + integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ== + postcss-js@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-3.0.3.tgz#2f0bd370a2e8599d45439f6970403b5873abda33" @@ -4844,6 +4914,13 @@ postcss-js@^3.0.3: camelcase-css "^2.0.1" postcss "^8.1.6" +postcss-js@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-4.0.0.tgz#31db79889531b80dc7bc9b0ad283e418dce0ac00" + integrity sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ== + dependencies: + camelcase-css "^2.0.1" + postcss-load-config@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.1.tgz#2f53a17f2f543d9e63864460af42efdac0d41f87" @@ -4859,7 +4936,7 @@ postcss-nested@5.0.6: dependencies: postcss-selector-parser "^6.0.6" -postcss-selector-parser@^6.0.6: +postcss-selector-parser@^6.0.6, postcss-selector-parser@^6.0.9: version "6.0.9" resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.9.tgz#ee71c3b9ff63d9cd130838876c13a2ec1a992b2f" integrity sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ== @@ -5301,7 +5378,7 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.20.0: +resolve@^1.20.0, resolve@^1.21.0: version "1.22.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== @@ -5892,6 +5969,32 @@ tailwindcss@3.0.1: resolve "^1.20.0" tmp "^0.2.1" +tailwindcss@^3.0.7: + version "3.0.18" + resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.0.18.tgz#ea4825e6496d77dc21877b6b61c7cc56cda3add5" + integrity sha512-ihPTpEyA5ANgZbwKlgrbfnzOp9R5vDHFWmqxB1PT8NwOGCOFVVMl+Ps1cQQ369acaqqf1BEF77roCwK0lvNmTw== + dependencies: + arg "^5.0.1" + chalk "^4.1.2" + chokidar "^3.5.3" + color-name "^1.1.4" + cosmiconfig "^7.0.1" + detective "^5.2.0" + didyoumean "^1.2.2" + dlv "^1.1.3" + fast-glob "^3.2.11" + glob-parent "^6.0.2" + is-glob "^4.0.3" + normalize-path "^3.0.0" + object-hash "^2.2.0" + postcss-js "^4.0.0" + postcss-load-config "^3.1.0" + postcss-nested "5.0.6" + postcss-selector-parser "^6.0.9" + postcss-value-parser "^4.2.0" + quick-lru "^5.1.1" + resolve "^1.21.0" + teeny-request@^7.0.0: version "7.1.3" resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-7.1.3.tgz#5a3d90c559a6c664a993477b138e331a518765ba" @@ -6013,6 +6116,21 @@ tty-browserify@0.0.1: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== +tw-elements@^1.0.0-alpha10: + version "1.0.0-alpha10" + resolved "https://registry.yarnpkg.com/tw-elements/-/tw-elements-1.0.0-alpha10.tgz#e37fc9505bff67f21826ee0f6c4b59fe0197ba56" + integrity sha512-7RacBxrJ0QBXb51YrYbbggS8mmxaTEK4cfxHN3ilQlWyK+BWZvPYQAITf489WOiGAnbLERQbwmoAE3eOpHwNqg== + dependencies: + "@popperjs/core" "^2.6.0" + bootstrap "^5.1.3" + chart.js "^2.9.4" + chartjs-plugin-datalabels "^0.7.0" + deepmerge "^4.2.2" + detect-autofill "^1.1.3" + perfect-scrollbar "^1.5.0" + popper.js "^1.16.1" + tailwindcss "^3.0.7" + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" From 587e1e5d6185d2ef72bd183b98f734865ec589f1 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 17:12:09 -0600 Subject: [PATCH 3/7] Add loading spinner while feed loads --- web/components/loading-indicator.tsx | 16 ++++++++++++++++ web/pages/home.tsx | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 web/components/loading-indicator.tsx diff --git a/web/components/loading-indicator.tsx b/web/components/loading-indicator.tsx new file mode 100644 index 00000000..0cfa01af --- /dev/null +++ b/web/components/loading-indicator.tsx @@ -0,0 +1,16 @@ +import clsx from 'clsx' + +export function LoadingIndicator(props: { className?: string }) { + const { className } = props + + return ( +
+
+ Loading... +
+
+ ) +} diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 61d785e4..187706d2 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -16,6 +16,7 @@ import { getFollowedFolds, listAllFolds } from '../lib/firebase/folds' import { Fold } from '../../common/fold' import { filterDefined } from '../../common/util/array' import { useUserBets } from '../hooks/use-user-bets' +import { LoadingIndicator } from '../components/loading-indicator' export async function getStaticProps() { const [contracts, folds] = await Promise.all([ @@ -136,7 +137,9 @@ const Home = (props: { contracts: Contract[]; folds: Fold[] }) => { contractBets={contractBets} contractComments={contractComments} /> - ) : null} + ) : ( + + )} From d170e31f54c03537b7dd09aa6b1f820bb065068d Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 17:30:40 -0600 Subject: [PATCH 4/7] Switch from onSnapshot to our listenForValues, which doesn't set with partial cached values --- web/lib/firebase/bets.ts | 14 ++++---------- web/lib/firebase/comments.ts | 15 +++++++-------- web/lib/firebase/contracts.ts | 5 +---- web/lib/firebase/users.ts | 12 ++++++------ 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/web/lib/firebase/bets.ts b/web/lib/firebase/bets.ts index 5397e8fe..642c07c4 100644 --- a/web/lib/firebase/bets.ts +++ b/web/lib/firebase/bets.ts @@ -2,7 +2,6 @@ import { collection, collectionGroup, query, - onSnapshot, where, orderBy, } from 'firebase/firestore' @@ -11,7 +10,7 @@ import _ from 'lodash' import { db } from './init' import { Bet } from '../../../common/bet' import { Contract } from '../../../common/contract' -import { getValues } from './utils' +import { getValues, listenForValues } from './utils' export type { Bet } function getBetsCollection(contractId: string) { @@ -51,11 +50,8 @@ export function listenForBets( contractId: string, setBets: (bets: Bet[]) => void ) { - return onSnapshot(getBetsCollection(contractId), (snap) => { - const bets = snap.docs.map((doc) => doc.data() as Bet) - + return listenForValues(getBetsCollection(contractId), (bets) => { bets.sort((bet1, bet2) => bet1.createdTime - bet2.createdTime) - setBets(bets) }) } @@ -68,9 +64,7 @@ export function listenForUserBets( collectionGroup(db, 'bets'), where('userId', '==', userId) ) - - return onSnapshot(userQuery, (snap) => { - const bets = snap.docs.map((doc) => doc.data() as Bet) + return listenForValues(userQuery, (bets) => { bets.sort((bet1, bet2) => bet1.createdTime - bet2.createdTime) setBets(bets) }) @@ -88,5 +82,5 @@ export function withoutAnteBets(contract: Contract, bets?: Bet[]) { return bets.slice(2) } - return bets ?? [] + return bets?.filter((bet) => !bet.isAnte) ?? [] } diff --git a/web/lib/firebase/comments.ts b/web/lib/firebase/comments.ts index d272581e..7072a71a 100644 --- a/web/lib/firebase/comments.ts +++ b/web/lib/firebase/comments.ts @@ -1,7 +1,6 @@ import { doc, collection, - onSnapshot, setDoc, query, collectionGroup, @@ -46,13 +45,13 @@ export function listenForComments( contractId: string, setComments: (comments: Comment[]) => void ) { - return onSnapshot(getCommentsCollection(contractId), (snap) => { - const comments = snap.docs.map((doc) => doc.data() as Comment) - - comments.sort((c1, c2) => c1.createdTime - c2.createdTime) - - setComments(comments) - }) + return listenForValues( + getCommentsCollection(contractId), + (comments) => { + comments.sort((c1, c2) => c1.createdTime - c2.createdTime) + setComments(comments) + } + ) } // Return a map of betId -> comment diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index 4789d19f..666c7caf 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -8,7 +8,6 @@ import { collection, query, getDocs, - onSnapshot, orderBy, getDoc, updateDoc, @@ -116,9 +115,7 @@ export function listenForContracts( setContracts: (contracts: Contract[]) => void ) { const q = query(contractCollection, orderBy('createdTime', 'desc')) - return onSnapshot(q, (snap) => { - setContracts(snap.docs.map((doc) => doc.data() as Contract)) - }) + return listenForValues(q, setContracts) } export function listenForContract( diff --git a/web/lib/firebase/users.ts b/web/lib/firebase/users.ts index 4141e6c6..57969bb6 100644 --- a/web/lib/firebase/users.ts +++ b/web/lib/firebase/users.ts @@ -3,7 +3,6 @@ import { doc, setDoc, getDoc, - onSnapshot, collection, query, where, @@ -22,7 +21,7 @@ import { import { app } from './init' import { PrivateUser, User } from '../../../common/user' import { createUser } from './api-call' -import { getValues, listenForValues } from './utils' +import { getValues, listenForValue, listenForValues } from './utils' export type { User } const db = getFirestore(app) @@ -46,11 +45,12 @@ export async function setUser(userId: string, user: User) { await setDoc(doc(db, 'users', userId), user) } -export function listenForUser(userId: string, setUser: (user: User) => void) { +export function listenForUser( + userId: string, + setUser: (user: User | null) => void +) { const userRef = doc(db, 'users', userId) - return onSnapshot(userRef, (userSnap) => { - setUser(userSnap.data() as User) - }) + return listenForValue(userRef, setUser) } const CACHED_USER_KEY = 'CACHED_USER_KEY' From c36ce3e521a076d452be226e7563399099ac8e5e Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 17:40:37 -0600 Subject: [PATCH 5/7] Change home tags to communities --- web/components/tags-list.tsx | 14 ++++++++------ web/pages/home.tsx | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/web/components/tags-list.tsx b/web/components/tags-list.tsx index 4894643b..80276897 100644 --- a/web/components/tags-list.tsx +++ b/web/components/tags-list.tsx @@ -1,7 +1,6 @@ import clsx from 'clsx' import { Row } from './layout/row' import { SiteLink } from './site-link' -import { Fold } from '../../common/fold' function Hashtag(props: { tag: string; noLink?: boolean }) { const { tag, noLink } = props @@ -45,11 +44,11 @@ export function TagsList(props: { ) } -export function FoldTag(props: { fold: Fold }) { +export function FoldTag(props: { fold: { slug: string; name: string } }) { const { fold } = props - const { name } = fold + const { slug, name } = fold return ( - +
@@ -70,7 +72,7 @@ export function FoldTagList(props: { folds: Fold[]; className?: string }) { <>
Communities
{folds.map((fold) => ( - + ))} )} diff --git a/web/pages/home.tsx b/web/pages/home.tsx index 96ee0a99..cea7c0a7 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -17,7 +17,7 @@ import { Fold } from '../../common/fold' import { filterDefined } from '../../common/util/array' import { useUserBets } from '../hooks/use-user-bets' import { LoadingIndicator } from '../components/loading-indicator' -import { TagsList } from '../components/tags-list' +import { FoldTagList } from '../components/tags-list' export async function getStaticProps() { const [contracts, folds] = await Promise.all([ @@ -131,19 +131,21 @@ const Home = (props: { contracts: Contract[]; folds: Fold[] }) => { - - + - + {activeContracts ? ( Date: Thu, 3 Feb 2022 18:10:19 -0600 Subject: [PATCH 6/7] Remove tw-elements for now --- web/components/loading-indicator.tsx | 6 +- web/package.json | 3 +- web/pages/_document.tsx | 1 - web/tailwind.config.js | 7 +- yarn.lock | 130 ++------------------------- 5 files changed, 10 insertions(+), 137 deletions(-) diff --git a/web/components/loading-indicator.tsx b/web/components/loading-indicator.tsx index 0cfa01af..7ef73099 100644 --- a/web/components/loading-indicator.tsx +++ b/web/components/loading-indicator.tsx @@ -6,11 +6,9 @@ export function LoadingIndicator(props: { className?: string }) { return (
- Loading... -
+ />
) } diff --git a/web/package.json b/web/package.json index 827030e4..92ca48d3 100644 --- a/web/package.json +++ b/web/package.json @@ -27,8 +27,7 @@ "next": "12.0.7", "react": "17.0.2", "react-dom": "17.0.2", - "react-expanding-textarea": "^2.3.4", - "tw-elements": "^1.0.0-alpha10" + "react-expanding-textarea": "^2.3.4" }, "devDependencies": { "@tailwindcss/forms": "0.4.0", diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx index c12afbab..d2ccc8e7 100644 --- a/web/pages/_document.tsx +++ b/web/pages/_document.tsx @@ -31,7 +31,6 @@ export default function Document() { `, }} /> - diff --git a/web/tailwind.config.js b/web/tailwind.config.js index 1d2335b4..e009e488 100644 --- a/web/tailwind.config.js +++ b/web/tailwind.config.js @@ -21,12 +21,7 @@ module.exports = { variants: { extend: {}, }, - plugins: [ - require('@tailwindcss/forms'), - require('daisyui'), - require('tw-elements/dist/plugin'), - ], - + plugins: [require('@tailwindcss/forms'), require('daisyui')], daisyui: { themes: [ { diff --git a/yarn.lock b/yarn.lock index 3efd42f4..ab0d8142 100644 --- a/yarn.lock +++ b/yarn.lock @@ -865,11 +865,6 @@ resolved "https://registry.yarnpkg.com/@panva/asn1.js/-/asn1.js-1.0.0.tgz#dd55ae7b8129e02049f009408b97c61ccf9032f6" integrity sha512-UdkG3mLEqXgnlKsWanWcgb6dOjUzJ+XC5f+aWw30qrtjxeNUSfKX1cd5FBzOaXQumoe9nIqeZUvrRJS03HCCtw== -"@popperjs/core@^2.6.0": - version "2.11.2" - resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.2.tgz#830beaec4b4091a9e9398ac50f865ddea52186b9" - integrity sha512-92FRmppjjqz29VMJ2dn+xdyXZBrMlE42AV6Kq6BwjWV7CNUW1hs2FtxSNLQE+gJhaZ6AAmYuO9y8dshhcBl7vA== - "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" @@ -1539,11 +1534,6 @@ boolbase@^1.0.0: resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= -bootstrap@^5.1.3: - version "5.1.3" - resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.1.3.tgz#ba081b0c130f810fa70900acbc1c6d3c28fa8f34" - integrity sha512-fcQztozJ8jToQWXxVuEyXWW+dSo8AiXWKwiSSrKWsRB/Qt+Ewwza+JWoLKiTuQLaEPhdNAJ7+Dosc9DOIqNy7Q== - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1736,34 +1726,6 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" -chart.js@^2.9.4: - version "2.9.4" - resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.9.4.tgz#0827f9563faffb2dc5c06562f8eb10337d5b9684" - integrity sha512-B07aAzxcrikjAPyV+01j7BmOpxtQETxTSlQ26BEYJ+3iUkbNKaOJ/nDbT6JjyqYxseM0ON12COHYdU2cTIjC7A== - dependencies: - chartjs-color "^2.1.0" - moment "^2.10.2" - -chartjs-color-string@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz#1df096621c0e70720a64f4135ea171d051402f71" - integrity sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A== - dependencies: - color-name "^1.0.0" - -chartjs-color@^2.1.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/chartjs-color/-/chartjs-color-2.4.1.tgz#6118bba202fe1ea79dd7f7c0f9da93467296c3b0" - integrity sha512-haqOg1+Yebys/Ts/9bLo/BqUcONQOdr/hoEr2LLTRl6C5LXctUdHxsCYfvQVg5JIxITrfCNUDr4ntqmQk9+/0w== - dependencies: - chartjs-color-string "^0.6.0" - color-convert "^1.9.3" - -chartjs-plugin-datalabels@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/chartjs-plugin-datalabels/-/chartjs-plugin-datalabels-0.7.0.tgz#f72e44edb2db45ef68913e9320bcc50398a205e6" - integrity sha512-PKVUX14nYhH0wcdCpgOoC39Gbzvn6cZ7O9n+bwc02yKD9FTnJ7/TSrBcfebmolFZp1Rcicr9xbT0a5HUbigS7g== - chokidar@3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" @@ -1779,7 +1741,7 @@ chokidar@3.5.1: optionalDependencies: fsevents "~2.3.1" -chokidar@^3.5.2, chokidar@^3.5.3: +chokidar@^3.5.2: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -1854,7 +1816,7 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= -color-convert@^1.9.0, color-convert@^1.9.3: +color-convert@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== @@ -1873,7 +1835,7 @@ color-name@1.1.3: resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= -color-name@^1.0.0, color-name@^1.1.4, color-name@~1.1.4: +color-name@^1.1.4, color-name@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== @@ -2130,11 +2092,6 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.10.tgz#2ad3a7bed70f35b965707c092e5f30b327c290e5" integrity sha512-2u44ZG2OcNUO9HDp/Jl8C07x6pU/eTR3ncV91SiK3dhG9TWvRVsCoJw14Ckx5DgWkzGA3waZWO3d7pgqpUI/XA== -custom-event-polyfill@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/custom-event-polyfill/-/custom-event-polyfill-1.0.7.tgz#9bc993ddda937c1a30ccd335614c6c58c4f87aee" - integrity sha512-TDDkd5DkaZxZFM8p+1I3yAlvM3rSr1wbrOliG4yJiwinMZN8z/iGL7BTlDkrJcYTmgUSb4ywVCc3ZaUtOtC76w== - d3-array@2, d3-array@^2.3.0: version "2.12.1" resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-2.12.1.tgz#e20b41aafcdffdf5d50928004ececf815a465e81" @@ -2294,11 +2251,6 @@ deep-is@^0.1.3, deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -deepmerge@^4.2.2: - version "4.2.2" - resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" - integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== - define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -2348,13 +2300,6 @@ destroy@~1.0.4: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= -detect-autofill@^1.1.3: - version "1.1.4" - resolved "https://registry.yarnpkg.com/detect-autofill/-/detect-autofill-1.1.4.tgz#1424ca5863c69a1e0373ea85a4f0edccc2357479" - integrity sha512-utCBQwCR/beSnADQmBC7C4tTueBBkYCl6WSpfGUkYKO/+MzPxqYGj6G4MvHzcKmH1gCTK+VunX2vaagvkRXPvA== - dependencies: - custom-event-polyfill "^1.0.7" - detective@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b" @@ -2969,7 +2914,7 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.2.11, fast-glob@^3.2.7, fast-glob@^3.2.9: +fast-glob@^3.2.7, fast-glob@^3.2.9: version "3.2.11" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== @@ -4363,11 +4308,6 @@ minimist@^1.1.1, minimist@^1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -moment@^2.10.2: - version "2.29.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" - integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== - mri@^1.1.5: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" @@ -4864,11 +4804,6 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" -perfect-scrollbar@^1.5.0: - version "1.5.5" - resolved "https://registry.yarnpkg.com/perfect-scrollbar/-/perfect-scrollbar-1.5.5.tgz#41a211a2fb52a7191eff301432134ea47052b27f" - integrity sha512-dzalfutyP3e/FOpdlhVryN4AJ5XDVauVWxybSkLZmakFE2sS3y3pc4JnSprw8tGmHvkaG5Edr5T7LBTZ+WWU2g== - performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" @@ -4901,11 +4836,6 @@ platform@1.3.6: resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7" integrity sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg== -popper.js@^1.16.1: - version "1.16.1" - resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b" - integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ== - postcss-js@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-3.0.3.tgz#2f0bd370a2e8599d45439f6970403b5873abda33" @@ -4914,13 +4844,6 @@ postcss-js@^3.0.3: camelcase-css "^2.0.1" postcss "^8.1.6" -postcss-js@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/postcss-js/-/postcss-js-4.0.0.tgz#31db79889531b80dc7bc9b0ad283e418dce0ac00" - integrity sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ== - dependencies: - camelcase-css "^2.0.1" - postcss-load-config@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-3.1.1.tgz#2f53a17f2f543d9e63864460af42efdac0d41f87" @@ -4936,7 +4859,7 @@ postcss-nested@5.0.6: dependencies: postcss-selector-parser "^6.0.6" -postcss-selector-parser@^6.0.6, postcss-selector-parser@^6.0.9: +postcss-selector-parser@^6.0.6: version "6.0.9" resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.9.tgz#ee71c3b9ff63d9cd130838876c13a2ec1a992b2f" integrity sha512-UO3SgnZOVTwu4kyLR22UQ1xZh086RyNZppb7lLAKBFK8a32ttG5i87Y/P3+2bRSjZNyJ1B7hfFNo273tKe9YxQ== @@ -5378,7 +5301,7 @@ resolve-from@^4.0.0: resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g== -resolve@^1.20.0, resolve@^1.21.0: +resolve@^1.20.0: version "1.22.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198" integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw== @@ -5969,32 +5892,6 @@ tailwindcss@3.0.1: resolve "^1.20.0" tmp "^0.2.1" -tailwindcss@^3.0.7: - version "3.0.18" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.0.18.tgz#ea4825e6496d77dc21877b6b61c7cc56cda3add5" - integrity sha512-ihPTpEyA5ANgZbwKlgrbfnzOp9R5vDHFWmqxB1PT8NwOGCOFVVMl+Ps1cQQ369acaqqf1BEF77roCwK0lvNmTw== - dependencies: - arg "^5.0.1" - chalk "^4.1.2" - chokidar "^3.5.3" - color-name "^1.1.4" - cosmiconfig "^7.0.1" - detective "^5.2.0" - didyoumean "^1.2.2" - dlv "^1.1.3" - fast-glob "^3.2.11" - glob-parent "^6.0.2" - is-glob "^4.0.3" - normalize-path "^3.0.0" - object-hash "^2.2.0" - postcss-js "^4.0.0" - postcss-load-config "^3.1.0" - postcss-nested "5.0.6" - postcss-selector-parser "^6.0.9" - postcss-value-parser "^4.2.0" - quick-lru "^5.1.1" - resolve "^1.21.0" - teeny-request@^7.0.0: version "7.1.3" resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-7.1.3.tgz#5a3d90c559a6c664a993477b138e331a518765ba" @@ -6116,21 +6013,6 @@ tty-browserify@0.0.1: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811" integrity sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw== -tw-elements@^1.0.0-alpha10: - version "1.0.0-alpha10" - resolved "https://registry.yarnpkg.com/tw-elements/-/tw-elements-1.0.0-alpha10.tgz#e37fc9505bff67f21826ee0f6c4b59fe0197ba56" - integrity sha512-7RacBxrJ0QBXb51YrYbbggS8mmxaTEK4cfxHN3ilQlWyK+BWZvPYQAITf489WOiGAnbLERQbwmoAE3eOpHwNqg== - dependencies: - "@popperjs/core" "^2.6.0" - bootstrap "^5.1.3" - chart.js "^2.9.4" - chartjs-plugin-datalabels "^0.7.0" - deepmerge "^4.2.2" - detect-autofill "^1.1.3" - perfect-scrollbar "^1.5.0" - popper.js "^1.16.1" - tailwindcss "^3.0.7" - type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1" From ca89fd158d245bdfd437e4be77243161e237404e Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 3 Feb 2022 19:00:17 -0600 Subject: [PATCH 7/7] Make home communities look better on mobile. Add Covid & AI. --- web/components/tags-list.tsx | 5 +++-- web/pages/home.tsx | 13 ++++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/web/components/tags-list.tsx b/web/components/tags-list.tsx index 80276897..33b54e96 100644 --- a/web/components/tags-list.tsx +++ b/web/components/tags-list.tsx @@ -63,14 +63,15 @@ export function FoldTag(props: { fold: { slug: string; name: string } }) { export function FoldTagList(props: { folds: { slug: string; name: string }[] + noLabel?: boolean className?: string }) { - const { folds, className } = props + const { folds, noLabel, className } = props return ( {folds.length > 0 && ( <> -
Communities
+ {!noLabel &&
Communities
} {folds.map((fold) => ( ))} diff --git a/web/pages/home.tsx b/web/pages/home.tsx index cea7c0a7..2eee39d3 100644 --- a/web/pages/home.tsx +++ b/web/pages/home.tsx @@ -112,15 +112,6 @@ const Home = (props: { contracts: Contract[]; folds: Fold[] }) => { ) : [] - console.log({ - followedFoldIds, - followedFolds, - yourBetContracts, - feedContracts, - feedBets, - feedComments, - }) - if (user === null) { Router.replace('/') return <> @@ -132,13 +123,17 @@ const Home = (props: { contracts: Contract[]; folds: Fold[] }) => { +
Communities