~meta sub

This commit is contained in:
keyan 2023-06-20 11:26:23 -05:00
parent 747371a4e4
commit 03e0646560
5 changed files with 19 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import { Form, Select } from './form'
import SearchIcon from '../svgs/search-line.svg'
import BackArrow from '../svgs/arrow-left-line.svg'
import { useNotification } from './notifications'
import { SUBS } from '../lib/constants'
function WalletSummary ({ me }) {
if (!me) return null
@ -225,7 +226,7 @@ export default function Header ({ sub }) {
onChange={(formik, e) => router.push(e.target.value === 'home' ? '/' : `/~${e.target.value}`)}
name='sub'
size='sm'
items={['home', 'bitcoin', 'nostr', 'tech', 'jobs']}
items={['home', ...SUBS]}
/>
</Form>
</Nav.Item>

View File

@ -1,6 +1,7 @@
import { useRouter } from 'next/router'
import { Select } from './form'
import Info from './info'
import { SUBS, SUBS_NO_JOBS } from '../lib/constants'
export function SubSelectInitial ({ sub }) {
const router = useRouter()
@ -22,6 +23,7 @@ export default function SubSelect ({ label, sub, setSub, item, ...props }) {
<li>If it's bitcoin related, put it in the bitcoin sub.</li>
<li>If it's nostr related, put it in the nostr sub.</li>
<li>If it's tech related, put it in the tech sub.</li>
<li>If it's stacker news related, put it in the meta sub.</li>
<li>If it's a job, put it in the jobs sub.</li>
</ul>
</div>
@ -44,7 +46,7 @@ export default function SubSelect ({ label, sub, setSub, item, ...props }) {
name='sub'
size='sm'
defaultValue={props.noForm ? sub : undefined}
items={props.noForm ? ['pick sub', 'bitcoin', 'nostr', 'tech', 'jobs'] : item ? ['bitcoin', 'nostr', 'tech'] : ['pick sub', 'bitcoin', 'nostr', 'tech']}
items={props.noForm ? ['pick sub', ...SUBS] : item ? SUBS_NO_JOBS : ['pick sub', ...SUBS_NO_JOBS]}
label={label &&
<>
{label}

View File

@ -17,3 +17,8 @@ export const MAX_POLL_NUM_CHOICES = 10
export const MIN_POLL_NUM_CHOICES = 2
export const ITEM_FILTER_THRESHOLD = 1.2
export const DONT_LIKE_THIS_COST = 1
// XXX this is temporary until we have so many subs they have
// to be loaded from the server
export const SUBS = ['bitcoin', 'nostr', 'tech', 'meta', 'jobs']
export const SUBS_NO_JOBS = SUBS.filter(s => s !== 'jobs')

View File

@ -1,5 +1,5 @@
import * as Yup from 'yup'
import { BOOST_MIN, MAX_POLL_CHOICE_LENGTH, MAX_TITLE_LENGTH, MAX_POLL_NUM_CHOICES, MIN_POLL_NUM_CHOICES } from './constants'
import { BOOST_MIN, MAX_POLL_CHOICE_LENGTH, MAX_TITLE_LENGTH, MAX_POLL_NUM_CHOICES, MIN_POLL_NUM_CHOICES, SUBS_NO_JOBS } from './constants'
import { NAME_QUERY } from '../fragments/users'
import { URL_REGEXP, WS_REGEXP } from './url'
import { SUPPORTED_CURRENCIES } from './currency'
@ -84,7 +84,7 @@ export function advPostSchemaMembers (client) {
export function subSelectSchemaMembers (client) {
return {
sub: Yup.string().required('required').oneOf(['bitcoin', 'nostr', 'tech'], 'required')
sub: Yup.string().required('required').oneOf(SUBS_NO_JOBS, 'required')
}
}

View File

@ -0,0 +1,7 @@
INSERT INTO "Sub" ("name", "desc", "postTypes", "rankingType")
VALUES ('meta', 'everything about SN', '{LINK,DISCUSSION,POLL,BOUNTY}', 'WOT') ON CONFLICT DO NOTHING;
-- transfer all posts related to SN to meta
UPDATE "Item"
SET "subName" = 'meta'
WHERE lower(title) SIMILAR TO lower('(% )?SN( %)?|(% )?k00b( %)?|(% )?keyan( %)?|(% )?SNL( %)?');