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