feat: 오늘 피드 — 사람 글을 묶음 대신 포스트처럼 두 장마다 한 장씩(큰 카드·댓글), 행사는 띠 대신 축제 전부와 팝업·전시·공연 2개씩 포스트로
- 사람 글 큰 카드: 머리줄·4:5 본문(사진, 없으면 글을 크게)·좋아요·댓글·보내기 - 사람 글 댓글: 로그인한 사람만, comment 표에 talk_id, talk.comment_count (init.sql) - '오늘 내 글'·'동네 사람들'·주제별 묶음, '이번 주 가까운 행사' 띠 제거 - 행사 포스트 자리 최대 40개, 앞쪽 절반에 다 못 들어가면 끝까지 한 장씩 걸러 - GA: feed_item_view(talk·event 노출), talk_comment
This commit is contained in:
1 parent
f6cb6f2deb
commit
dba3d78f14
22 files changed
+653
-318
No files matched your search
@@ -1,11 +1,9 @@
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { useState } from 'react'
|
||||
import { listMyTalksInfiniteOptions, listMyTalksOptions, listTalksInfiniteOptions, talkGroupsOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { TalkTopic, type TalkData } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { kst } from '@nalssigak/shared/lib'
|
||||
import { useInfiniteQuery } from '@tanstack/react-query'
|
||||
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions } from '@nalssigak/shared/api/client/@tanstack/react-query.gen'
|
||||
import { TalkTopic } from '@nalssigak/shared/api/client/types.gen'
|
||||
import { useRegion } from './regionContext'
|
||||
|
||||
// 글 주제와 피드 묶음 이름
|
||||
// 글 주제와 이름
|
||||
export const TOPICS = [
|
||||
[TalkTopic.LOCAL, '동네 이야기'],
|
||||
[TalkTopic.SKY, '하늘·노을'],
|
||||
@@ -15,14 +13,6 @@ export const TOPICS = [
|
||||
] 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()
|
||||
@@ -39,17 +29,6 @@ export function useTopicTalks(topic?: TalkTopic) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 오늘(한국 날짜) 쓴 내 글, 최신순. 로그인했을 때만 받는다 */
|
||||
export function useTodayMyTalks(loggedIn: boolean) {
|
||||
const q = useQuery({ ...listMyTalksOptions(), enabled: loggedIn })
|
||||
// 오늘 날짜는 화면을 연 때 기준으로 한 번만
|
||||
const [now] = useState(() => kst(new Date()))
|
||||
return (q.data?.talks ?? []).filter((t) => {
|
||||
const d = kst(t.created_at)
|
||||
return d.y === now.y && d.mo === now.mo && d.d === now.d
|
||||
})
|
||||
}
|
||||
|
||||
/** 내가 쓴 글 (최신순) */
|
||||
export function useMyTalks(enabled = true) {
|
||||
const list = useInfiniteQuery({
|
||||
|
||||
Reference in new issue
Block a user