Folds query on lowercase tags. Adding to description updates tags & lowercaseTags fields.
This commit is contained in:
parent
8b0091f30d
commit
2ea05f8913
|
@ -22,7 +22,7 @@ service cloud.firestore {
|
||||||
match /contracts/{contractId} {
|
match /contracts/{contractId} {
|
||||||
allow read;
|
allow read;
|
||||||
allow update: if resource.data.creatorId == request.auth.uid && request.resource.data.diff(resource.data).affectedKeys()
|
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;
|
allow delete: if resource.data.creatorId == request.auth.uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import { JoinSpans } from './join-spans'
|
||||||
import Textarea from 'react-expanding-textarea'
|
import Textarea from 'react-expanding-textarea'
|
||||||
import { outcome } from '../../common/contract'
|
import { outcome } from '../../common/contract'
|
||||||
import { fromNow } from '../lib/util/time'
|
import { fromNow } from '../lib/util/time'
|
||||||
|
import { parseTags } from '../../common/util/parse'
|
||||||
|
|
||||||
export function AvatarWithIcon(props: { username: string; avatarUrl: string }) {
|
export function AvatarWithIcon(props: { username: string; avatarUrl: string }) {
|
||||||
const { username, avatarUrl } = props
|
const { username, avatarUrl } = props
|
||||||
|
@ -170,7 +171,13 @@ export function ContractDescription(props: {
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
|
|
||||||
const newDescription = `${contract.description}\n\n${description}`.trim()
|
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())
|
setDescription(editStatement())
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,14 @@ export async function getFoldContracts(fold: Fold) {
|
||||||
// TODO: if tags.length > 10, execute multiple parallel queries
|
// TODO: if tags.length > 10, execute multiple parallel queries
|
||||||
tags.length > 0
|
tags.length > 0
|
||||||
? getValues<Contract>(
|
? getValues<Contract>(
|
||||||
query(contractCollection, where('tags', 'array-contains-any', tags))
|
query(
|
||||||
|
contractCollection,
|
||||||
|
where(
|
||||||
|
'lowercaseTags',
|
||||||
|
'array-contains-any',
|
||||||
|
tags.map((tag) => tag.toLowerCase())
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
: [],
|
: [],
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,6 @@ export default function FoldPage(props: {
|
||||||
topTraderScores: number[]
|
topTraderScores: number[]
|
||||||
topCreators: User[]
|
topCreators: User[]
|
||||||
topCreatorScores: number[]
|
topCreatorScores: number[]
|
||||||
params: { tab: string }
|
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
curator,
|
curator,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user