diff --git a/firestore.rules b/firestore.rules index 7d24cf66..894367a6 100644 --- a/firestore.rules +++ b/firestore.rules @@ -22,7 +22,7 @@ service cloud.firestore { match /contracts/{contractId} { allow read; allow update: if resource.data.creatorId == request.auth.uid && request.resource.data.diff(resource.data).affectedKeys() - .hasOnly(['description']); + .hasOnly(['description', 'tags', 'lowercaseTags']); allow delete: if resource.data.creatorId == request.auth.uid; } diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx index 99a4edb0..e90f5544 100644 --- a/web/components/contract-feed.tsx +++ b/web/components/contract-feed.tsx @@ -38,6 +38,7 @@ import { JoinSpans } from './join-spans' import Textarea from 'react-expanding-textarea' import { outcome } from '../../common/contract' import { fromNow } from '../lib/util/time' +import { parseTags } from '../../common/util/parse' export function AvatarWithIcon(props: { username: string; avatarUrl: string }) { const { username, avatarUrl } = props @@ -170,7 +171,13 @@ export function ContractDescription(props: { setEditing(false) const newDescription = `${contract.description}\n\n${description}`.trim() - await updateContract(contract.id, { description: newDescription }) + const tags = parseTags(`${contract.tags.join(' ')} ${newDescription}`) + const lowercaseTags = tags.map((tag) => tag.toLowerCase()) + await updateContract(contract.id, { + description: newDescription, + tags, + lowercaseTags, + }) setDescription(editStatement()) } diff --git a/web/lib/firebase/folds.ts b/web/lib/firebase/folds.ts index 8d2b850a..3220f884 100644 --- a/web/lib/firebase/folds.ts +++ b/web/lib/firebase/folds.ts @@ -45,7 +45,14 @@ export async function getFoldContracts(fold: Fold) { // TODO: if tags.length > 10, execute multiple parallel queries tags.length > 0 ? getValues( - query(contractCollection, where('tags', 'array-contains-any', tags)) + query( + contractCollection, + where( + 'lowercaseTags', + 'array-contains-any', + tags.map((tag) => tag.toLowerCase()) + ) + ) ) : [], diff --git a/web/pages/fold/[...slugs]/index.tsx b/web/pages/fold/[...slugs]/index.tsx index 220f2ec4..9845def9 100644 --- a/web/pages/fold/[...slugs]/index.tsx +++ b/web/pages/fold/[...slugs]/index.tsx @@ -120,7 +120,6 @@ export default function FoldPage(props: { topTraderScores: number[] topCreators: User[] topCreatorScores: number[] - params: { tab: string } }) { const { curator,