exclude certain categories for new users
This commit is contained in:
parent
1b3b4eb6d8
commit
d4f2a81735
|
@ -1,3 +1,5 @@
|
||||||
|
import { difference } from 'lodash'
|
||||||
|
|
||||||
export const CATEGORIES = {
|
export const CATEGORIES = {
|
||||||
politics: 'Politics',
|
politics: 'Politics',
|
||||||
technology: 'Technology',
|
technology: 'Technology',
|
||||||
|
@ -12,10 +14,19 @@ export const CATEGORIES = {
|
||||||
crypto: 'Crypto',
|
crypto: 'Crypto',
|
||||||
gaming: 'Gaming',
|
gaming: 'Gaming',
|
||||||
fun: 'Fun',
|
fun: 'Fun',
|
||||||
} as { [category: string]: string }
|
}
|
||||||
|
|
||||||
|
export type category = keyof typeof CATEGORIES
|
||||||
|
|
||||||
export const TO_CATEGORY = Object.fromEntries(
|
export const TO_CATEGORY = Object.fromEntries(
|
||||||
Object.entries(CATEGORIES).map(([k, v]) => [v, k])
|
Object.entries(CATEGORIES).map(([k, v]) => [v, k])
|
||||||
)
|
)
|
||||||
|
|
||||||
export const CATEGORY_LIST = Object.keys(CATEGORIES)
|
export const CATEGORY_LIST = Object.keys(CATEGORIES)
|
||||||
|
|
||||||
|
export const EXCLUDED_CATEGORIES: category[] = ['fun', 'manifold', 'personal']
|
||||||
|
|
||||||
|
export const DEFAULT_CATEGORIES = difference(
|
||||||
|
CATEGORY_LIST,
|
||||||
|
EXCLUDED_CATEGORIES
|
||||||
|
)
|
||||||
|
|
|
@ -15,6 +15,8 @@ import {
|
||||||
} from '../../common/util/clean-username'
|
} from '../../common/util/clean-username'
|
||||||
import { sendWelcomeEmail } from './emails'
|
import { sendWelcomeEmail } from './emails'
|
||||||
import { isWhitelisted } from '../../common/envs/constants'
|
import { isWhitelisted } from '../../common/envs/constants'
|
||||||
|
import { DEFAULT_CATEGORIES } from '../../common/categories'
|
||||||
|
|
||||||
import { track } from './analytics'
|
import { track } from './analytics'
|
||||||
|
|
||||||
export const createUser = functions
|
export const createUser = functions
|
||||||
|
@ -70,6 +72,7 @@ export const createUser = functions
|
||||||
createdTime: Date.now(),
|
createdTime: Date.now(),
|
||||||
totalPnLCached: 0,
|
totalPnLCached: 0,
|
||||||
creatorVolumeCached: 0,
|
creatorVolumeCached: 0,
|
||||||
|
followedCategories: DEFAULT_CATEGORIES,
|
||||||
}
|
}
|
||||||
|
|
||||||
await firestore.collection('users').doc(userId).create(user)
|
await firestore.collection('users').doc(userId).create(user)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { ENV } from 'common/envs/constants'
|
||||||
import { useUser } from 'web/hooks/use-user'
|
import { useUser } from 'web/hooks/use-user'
|
||||||
import { useFollows } from 'web/hooks/use-follows'
|
import { useFollows } from 'web/hooks/use-follows'
|
||||||
import { EditCategoriesButton } from './feed/category-selector'
|
import { EditCategoriesButton } from './feed/category-selector'
|
||||||
import { CATEGORIES } from 'common/categories'
|
import { CATEGORIES, category } from 'common/categories'
|
||||||
import { Tabs } from './layout/tabs'
|
import { Tabs } from './layout/tabs'
|
||||||
import { EditFollowingButton } from './following-button'
|
import { EditFollowingButton } from './following-button'
|
||||||
import { track } from '@amplitude/analytics-browser'
|
import { track } from '@amplitude/analytics-browser'
|
||||||
|
@ -264,7 +264,7 @@ function CategoryFollowSelector(props: {
|
||||||
if (followedCategories.length) {
|
if (followedCategories.length) {
|
||||||
const categoriesLabel = followedCategories
|
const categoriesLabel = followedCategories
|
||||||
.slice(0, 3)
|
.slice(0, 3)
|
||||||
.map((cat) => CATEGORIES[cat])
|
.map((cat) => CATEGORIES[cat as category])
|
||||||
.join(', ')
|
.join(', ')
|
||||||
const andMoreLabel =
|
const andMoreLabel =
|
||||||
followedCategories.length > 3
|
followedCategories.length > 3
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { PencilIcon } from '@heroicons/react/outline'
|
||||||
import { union, difference } from 'lodash'
|
import { union, difference } from 'lodash'
|
||||||
|
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { CATEGORIES, CATEGORY_LIST } from '../../../common/categories'
|
import { CATEGORIES, category, CATEGORY_LIST } from '../../../common/categories'
|
||||||
import { Modal } from '../layout/modal'
|
import { Modal } from '../layout/modal'
|
||||||
import { Col } from '../layout/col'
|
import { Col } from '../layout/col'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
@ -47,7 +47,7 @@ export function CategorySelector(props: {
|
||||||
{CATEGORY_LIST.map((cat) => (
|
{CATEGORY_LIST.map((cat) => (
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
key={cat}
|
key={cat}
|
||||||
category={CATEGORIES[cat].split(' ')[0]}
|
category={CATEGORIES[cat as category].split(' ')[0]}
|
||||||
isFollowed={cat === category}
|
isFollowed={cat === category}
|
||||||
toggle={() => {
|
toggle={() => {
|
||||||
setCategory(cat)
|
setCategory(cat)
|
||||||
|
@ -149,7 +149,7 @@ function CategorySelectorModal(props: {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
className="col-span-1"
|
className="col-span-1"
|
||||||
key={cat}
|
key={cat}
|
||||||
label={CATEGORIES[cat].split(' ')[0]}
|
label={CATEGORIES[cat as category].split(' ')[0]}
|
||||||
checked={followedCategories.includes(cat)}
|
checked={followedCategories.includes(cat)}
|
||||||
toggle={(checked) => {
|
toggle={(checked) => {
|
||||||
updateUser(user.id, {
|
updateUser(user.id, {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { CATEGORIES } from '../../common/categories'
|
import { CATEGORIES, category } from '../../common/categories'
|
||||||
import { Col } from './layout/col'
|
import { Col } from './layout/col'
|
||||||
|
|
||||||
import { Row } from './layout/row'
|
import { Row } from './layout/row'
|
||||||
|
@ -7,7 +7,7 @@ import { SiteLink } from './site-link'
|
||||||
|
|
||||||
function Hashtag(props: { tag: string; noLink?: boolean }) {
|
function Hashtag(props: { tag: string; noLink?: boolean }) {
|
||||||
const { tag, noLink } = props
|
const { tag, noLink } = props
|
||||||
const category = CATEGORIES[tag.replace('#', '').toLowerCase()]
|
const category = CATEGORIES[tag.replace('#', '').toLowerCase() as category]
|
||||||
|
|
||||||
const body = (
|
const body = (
|
||||||
<div className={clsx('', !noLink && 'cursor-pointer')}>
|
<div className={clsx('', !noLink && 'cursor-pointer')}>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user