chore: main 병합 — 로그인 없이 댓글·좋아요, 구글 로그인만, 동네 이야기·카드뉴스 등 (차단 표 user_block 하나로 합침, 익명 댓글도 신고 가능)

This commit is contained in:
minaChoi committed 2026-10-26 10:00:40 +09:00
commit dba34675c8
408 files changed
+36377 -725

No files matched your search

+10 -8
View File
@@ -1,19 +1,19 @@
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
import { matchPath, useLocation, useNavigate } from 'react-router'
import { useLocation, useNavigate } from 'react-router'
import regionPages from '../../seo/region.json'
import { nearestRegion } from '@nalssigak/shared/api/client/sdk.gen'
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
import { track } from '../lib/analytics'
import { DEFAULT_REGION, RegionContext, type LocateStatus } from './regionContext'
import { DEFAULT_REGION, ownPage, RegionContext, type LocateStatus } from './regionContext'
const KEY = 'nalssigak.b.region'
type RegionPage = (typeof regionPages)[number]
/** /today/gyeonggi/seongnam 같은 지역 페이지 주소면 그 페이지 */
/** /today/gyeonggi/seongnam, /tomorrow/gyeonggi/seongnam/bundang 같은 지역 페이지 주소면 그 페이지 */
function pageOf(pathname: string): RegionPage | undefined {
const m = matchPath('/today/:sido/:place', pathname)
return m ? regionPages.find((p) => p.path === `${m.params.sido}/${m.params.place}`) : undefined
const path = pathname.match(/^\/(?:today|tomorrow)\/([a-z]+\/[a-z]+(?:\/[a-z]+)?)\/?$/)?.[1]
return path ? regionPages.find((p) => p.path === path) : undefined
}
/** 지역 페이지 안의 구: 구로 나뉜 시는 r 이 그 시 안이면 r, 아니면 시청이 있는 구 */
@@ -45,9 +45,11 @@ export function RegionProvider({ children }: { children: ReactNode }) {
const navigate = useNavigate()
const page = pageOf(pathname)
const pageRef = useRef(page)
const dayRef = useRef(pathname.startsWith('/tomorrow/') ? 'tomorrow' : 'today')
useEffect(() => {
pageRef.current = page
}, [page])
dayRef.current = pathname.startsWith('/tomorrow/') ? 'tomorrow' : 'today'
}, [page, pathname])
const [stored] = useState(readStored)
const [landing] = useState(page)
const [chosen, setRegionState] = useState<RegionData>(() => (page ? regionIn(page, stored) : (stored ?? DEFAULT_REGION)))
@@ -60,8 +62,8 @@ export function RegionProvider({ children }: { children: ReactNode }) {
const setRegion = useCallback((r: RegionData) => {
setRegionState(r)
writeStored(r)
const next = regionPages.find((p) => p.regions.some((g) => g.code === r.code))
if (pageRef.current && next && next !== pageRef.current) navigate(`/today/${next.path}`)
const next = ownPage(r.code)
if (pageRef.current && next && next !== pageRef.current) navigate(`/${dayRef.current}/${next.path}`)
}, [navigate])
// quiet 면 못 찾아도 상태를 바꾸지 않는다 (사람이 누른 게 아니라 안내 문구를 띄우지 않음)