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

+53
View File
@@ -0,0 +1,53 @@
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions, talkGroupsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
import { TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
import { useRegion } from './regionContext'
// 글 주제와 피드 묶음 이름
export const TOPICS = [
[TalkTopic.LOCAL, '동네 이야기'],
[TalkTopic.SKY, '하늘·노을'],
[TalkTopic.RAIN, '비·눈'],
[TalkTopic.FOLIAGE, '단풍·꽃'],
[TalkTopic.OUTFIT, '오늘 옷차림'],
] as const
export const topicName = (t?: number) => TOPICS.find(([k]) => k === t)?.[1] ?? '동네 이야기'
/** 오늘 피드 묶음: 0 은 '동네 사람들', 나머지는 주제별(3장 이상일 때만 옴) */
export function useTalkGroups() {
const { region } = useRegion()
const q = useQuery(talkGroupsOptions({ query: { region: region.code } }))
const groups = new Map<number, TalkData[]>((q.data?.groups ?? []).map((g) => [g.topic, g.talks ?? []]))
return { groups, loaded: q.isSuccess }
}
/** 주제별 글 페이지 목록 (topic 없으면 전체) */
export function useTopicTalks(topic?: TalkTopic) {
const { region } = useRegion()
const list = useInfiniteQuery({
...listTalksInfiniteOptions({ query: { region: region.code, ...(topic ? { topic } : {}) } }),
initialPageParam: {},
getNextPageParam: (last) => last.next_cursor ?? undefined,
})
return {
talks: list.data?.pages.flatMap((p) => p.talks ?? []) ?? [],
loaded: list.isSuccess,
more: list.hasNextPage && !list.isFetchingNextPage,
loadMore: list.fetchNextPage,
}
}
/** 내가 쓴 글 (최신순) */
export function useMyTalks() {
const list = useInfiniteQuery({
...listMyTalksInfiniteOptions(),
initialPageParam: {},
getNextPageParam: (last) => last.next_cursor ?? undefined,
})
return {
talks: list.data?.pages.flatMap((p) => p.talks ?? []) ?? [],
loaded: list.isSuccess,
more: list.hasNextPage && !list.isFetchingNextPage,
loadMore: list.fetchNextPage,
}
}