From 03e54ad552a2dd1712462f49711285817ce81c17 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Fri, 23 Oct 2026 14:53:59 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EB=8B=A8=ED=92=8D=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=C2=B7=EC=9D=B4=EB=B2=88=20=EC=A3=BC=20=ED=96=89?= =?UTF-8?q?=EC=82=AC=20=EB=9D=A0=C2=B7=EA=B3=84=EC=A0=88=20=EC=9D=B4?= =?UTF-8?q?=EC=95=BC=EA=B8=B0=20=EB=9D=A0=EC=97=90=20=EC=A2=8B=EC=95=84?= =?UTF-8?q?=EC=9A=94=C2=B7=EB=8C=93=EA=B8=80(=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=ED=8F=AC=EC=8A=A4=ED=8A=B8=20=EC=9E=90=EB=A6=AC=2018=C2=B719?= =?UTF-8?q?=C2=B720),=20=ED=9E=88=EC=96=B4=EB=A1=9C=20=EC=95=84=EB=9E=98?= =?UTF-8?q?=20=EA=B8=80=EC=9E=90=20=EC=B9=B8=20=EB=86=92=EC=9D=B4=EB=A5=BC?= =?UTF-8?q?=20=EB=AF=B8=EB=A6=AC=20=EC=9E=A1=EC=95=84=20=EC=98=A4=EB=8A=98?= =?UTF-8?q?=EC=9D=98=20=EA=B0=81=EB=B6=80=ED=84=B0=20=ED=94=BC=EB=93=9C?= =?UTF-8?q?=EA=B0=80=20=EB=B0=80=EB=A0=A4=20=EB=82=B4=EB=A0=A4=EA=B0=80?= =?UTF-8?q?=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/common/enums.py | 3 +++ backend/router/v1/feed/feed.py | 2 +- backend/router/v1/feed/protocol.py | 5 ++++- backend/services/feed_service.py | 12 ++++++++--- frontend/src/api/client/types.gen.ts | 19 +++++++++++++++-- frontend/src/b/Post.tsx | 3 +++ frontend/src/b/TodayPage.tsx | 32 ++++++++++++++++------------ frontend/src/b/foliageMap.tsx | 5 +++-- frontend/src/b/pinnedLike.ts | 4 ++-- 9 files changed, 60 insertions(+), 25 deletions(-) diff --git a/backend/common/enums.py b/backend/common/enums.py index 7759acf..6aa8ae5 100644 --- a/backend/common/enums.py +++ b/backend/common/enums.py @@ -147,6 +147,9 @@ class PostType(CodeEnum): UV = 15 # 오늘 낮 자외선 (아침·낮, '보통' 이상인 날만) HERO = 16 # 히어로(오늘 날씨)의 좋아요·댓글 자리. 피드 목록엔 안 나온다 TODAY_GAK = 17 # 오늘의 각 카드의 좋아요·댓글 자리. 피드 목록엔 안 나온다 + FOLIAGE = 18 # 단풍 지도 카드의 좋아요·댓글 자리. 피드 목록엔 안 나온다 + EVENTS_BAND = 19 # 이번 주 가까운 행사 띠의 좋아요·댓글 자리 + SEASON_BAND = 20 # 이번 주 계절 이야기 띠의 좋아요·댓글 자리 class EventKind(CodeEnum): diff --git a/backend/router/v1/feed/feed.py b/backend/router/v1/feed/feed.py index 5296168..05059bd 100644 --- a/backend/router/v1/feed/feed.py +++ b/backend/router/v1/feed/feed.py @@ -22,7 +22,7 @@ async def get_feed( err, feed = await service.feed(region) if err is not ErrorType.SUCCESS: return Res_Feed(result=error_info(err)) - pinned = [x for x in (feed.hero_post, feed.gak_post) if x is not None] + pinned = [x for x in (feed.hero_post, feed.gak_post, feed.foliage_post, feed.events_post, feed.season_post) if x is not None] ids = [p.post_id for p in feed.posts] + [x.post_id for x in pinned] counts = await reactions.counts(ids) liked, saved = await reactions.marks(user, ids) diff --git a/backend/router/v1/feed/protocol.py b/backend/router/v1/feed/protocol.py index 00665a9..fd2c7a9 100644 --- a/backend/router/v1/feed/protocol.py +++ b/backend/router/v1/feed/protocol.py @@ -137,7 +137,7 @@ class PostData(WebPacketProtocol): class PostReaction(WebPacketProtocol): - """포스트 틀이 아닌 카드(히어로·오늘의 각)에 붙는 좋아요·댓글.""" + """포스트 틀이 아닌 카드(히어로·오늘의 각·단풍 지도·띠)에 붙는 좋아요·댓글.""" post_id: int like_count: int comment_count: int @@ -235,6 +235,9 @@ class Res_Feed(Res_WebPacketProtocol): posts: list[PostData] = [] hero_post: Optional[PostReaction] = None gak_post: Optional[PostReaction] = None + foliage_post: Optional[PostReaction] = None + events_post: Optional[PostReaction] = None + season_post: Optional[PostReaction] = None bands: Optional[Bands] = None diff --git a/backend/services/feed_service.py b/backend/services/feed_service.py index 1334070..22309e5 100644 --- a/backend/services/feed_service.py +++ b/backend/services/feed_service.py @@ -65,12 +65,18 @@ LINEUP = [ (20, PostType.UV, RefType.NONE, None), (21, PostType.HERO, RefType.NONE, None), (22, PostType.TODAY_GAK, RefType.NONE, None), + (23, PostType.FOLIAGE, RefType.NONE, None), + (24, PostType.EVENTS_BAND, RefType.NONE, None), + (25, PostType.SEASON_BAND, RefType.NONE, None), ] -# 피드 목록 대신 히어로·오늘의 각 카드에 좋아요·댓글만 붙는 자리 -_PINNED = {PostType.HERO: "hero_post", PostType.TODAY_GAK: "gak_post"} +# 피드 목록 대신 히어로·오늘의 각·단풍 지도·띠에 좋아요·댓글만 붙는 자리 +_PINNED = { + PostType.HERO: "hero_post", PostType.TODAY_GAK: "gak_post", PostType.FOLIAGE: "foliage_post", + PostType.EVENTS_BAND: "events_post", PostType.SEASON_BAND: "season_post", +} # 좋아요·댓글 단위. 이 종류들은 전국이 같은 카드 하나, 나머지는 그 구 데이터로 채우는 카드라 시도마다 따로 만든다. NATIONAL_SCOPE = "00" -NATIONAL_TYPES = frozenset({PostType.SEASON, PostType.TIP, PostType.QUOTE, PostType.MOON}) +NATIONAL_TYPES = frozenset({PostType.SEASON, PostType.TIP, PostType.QUOTE, PostType.MOON, PostType.FOLIAGE, PostType.SEASON_BAND}) def sido_of(region_code: str) -> str: diff --git a/frontend/src/api/client/types.gen.ts b/frontend/src/api/client/types.gen.ts index 8699d3b..7272acf 100644 --- a/frontend/src/api/client/types.gen.ts +++ b/frontend/src/api/client/types.gen.ts @@ -1192,7 +1192,7 @@ export type PostData = { /** * PostReaction * - * 포스트 틀이 아닌 카드(히어로·오늘의 각)에 붙는 좋아요·댓글. + * 포스트 틀이 아닌 카드(히어로·오늘의 각·단풍 지도·띠)에 붙는 좋아요·댓글. */ export type PostReaction = { /** @@ -1284,7 +1284,19 @@ export const PostType = { /** * TODAY_GAK */ - TODAY_GAK: 17 + TODAY_GAK: 17, + /** + * FOLIAGE + */ + FOLIAGE: 18, + /** + * EVENTS_BAND + */ + EVENTS_BAND: 19, + /** + * SEASON_BAND + */ + SEASON_BAND: 20 } as const; /** @@ -1726,6 +1738,9 @@ export type ResFeed = { posts?: Array; hero_post?: PostReaction | null; gak_post?: PostReaction | null; + foliage_post?: PostReaction | null; + events_post?: PostReaction | null; + season_post?: PostReaction | null; bands?: Bands | null; }; diff --git a/frontend/src/b/Post.tsx b/frontend/src/b/Post.tsx index 873d8bc..9e9be8b 100644 --- a/frontend/src/b/Post.tsx +++ b/frontend/src/b/Post.tsx @@ -31,6 +31,9 @@ const ACCOUNTS: Record = { [PostType.UV]: ['자외선', 'glasses'], [PostType.HERO]: ['오늘 날씨', 'sun'], [PostType.TODAY_GAK]: ['오늘의 각', 'rabbit'], + [PostType.FOLIAGE]: ['단풍 지도', 'maple'], + [PostType.EVENTS_BAND]: ['이번 주 가까운 행사', 'fireworks'], + [PostType.SEASON_BAND]: ['이번 주 계절 이야기', 'fallen_leaf'], } type Slide = HoursSlide | RowsSlide | GakSlide | SunsetSlide | WeekSlide | PlanSlide diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index d339daf..d64ba3e 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -21,7 +21,7 @@ import { InstallBanner } from './installBanner' import { MyGakRow } from './myGak' import { fromShare } from './myGakState' import { PostCard, PostCardSkel, PostFrame } from './Post' -import { usePinnedLike } from './pinnedLike' +import { usePinnedLike, type PinnedKey } from './pinnedLike' import { FeedComposer, TalkCard } from './talk' import { useFeedTalks } from './talkState' import { useRegion } from './regionContext' @@ -399,7 +399,8 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps -
+ {/* 다 불러온 높이(한 줄 말·날씨 한 줄·상태 두 줄)를 미리 잡아 둔다: 늦게 채워지며 아래 피드가 밀려 내려가지 않게 */} +
{top1 ? ( + ))} +
+ {loaded && !talks.length &&

아직 이 주제 글이 없어요. 오늘 탭에서 첫 글을 써 주세요.

} + {talks.map((t) => ( + + ))} + {more && ( + + )} + + ) +} diff --git a/frontend/src/b/TodayPage.tsx b/frontend/src/b/TodayPage.tsx index d64ba3e..41408cd 100644 --- a/frontend/src/b/TodayPage.tsx +++ b/frontend/src/b/TodayPage.tsx @@ -3,8 +3,10 @@ import { Link, useLocation } from 'react-router' import { useQuery } from '@tanstack/react-query' import { getFeedOptions, getWeatherTodayOptions } from '../api/client/@tanstack/react-query.gen' import { + PostType, RainType, Sky, + TalkTopic, type BandArticle, type BandEvent, type Hero as HeroData, @@ -22,8 +24,8 @@ import { MyGakRow } from './myGak' import { fromShare } from './myGakState' import { PostCard, PostCardSkel, PostFrame } from './Post' import { usePinnedLike, type PinnedKey } from './pinnedLike' -import { FeedComposer, TalkCard } from './talk' -import { useFeedTalks } from './talkState' +import { FeedComposer, NearTalks, TalkCard, TalkGroup } from './talk' +import { topicName, useTalkGroups } from './talkState' import { useRegion } from './regionContext' import { useSheet } from './sheetContext' import { useSky } from './skyContext' @@ -365,7 +367,7 @@ function Hero({ hero, post, today, ranked, all, feedLoad, todayLoad }: HeroProps ))} -
+
{/* 안 보이는 쪽을 덮어 오늘 밤 달 모양으로 */} {moon && ( @@ -572,8 +574,6 @@ function SeasonBand({ news, post }: { news: BandArticle[]; post?: PostReaction | ) } -const TALK_EVERY = 3 - export function TodayPage() { const { region } = useRegion() const feed = useQuery(getFeedOptions({ query: { region: region.code } })) @@ -588,19 +588,18 @@ export function TodayPage() { const nowAt = f?.hero?.now_at const load = loadOf(feed) const [mine, setMine] = useState([]) - // 사람들이 쓴 글은 4·7·10번째 포스트 뒤에 하나씩(3번째 뒤 행사 띠와 안 붙게), 남은 글은 피드 끝에. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고 - const feedTalks = useFeedTalks() - const talks = feedTalks.talks.filter((t) => !mine.some((m) => m.talk_id === t.talk_id)) - const between = Math.max(0, Math.floor((posts.length - 1) / TALK_EVERY)) - const moreRef = useRef(null) - const { more, loadMore } = feedTalks - useEffect(() => { - const el = moreRef.current - if (!el || !more) return - const io = new IntersectionObserver((es) => es.some((e) => e.isIntersecting) && loadMore(), { rootMargin: '600px' }) - io.observe(el) - return () => io.disconnect() - }, [more, loadMore]) + // 사람 글은 묶음으로: '동네 사람들'은 오늘의 각 아래, 주제 묶음은 같은 주제 포스트 아래. 방금 올린 내 글은 글쓰기 칸 아래에 따로 있으니 빼고 + const talkGroups = useTalkGroups() + const groupOf = (topic: number) => (talkGroups.groups.get(topic) ?? []).filter((t) => !mine.some((m) => m.talk_id === t.talk_id)) + const group = (topic: number) => { + const talks = groupOf(topic) + return talks.length ? : null + } + // 비·눈이 오거나 2시간 안에 올 때만 비·눈 묶음을 히어로 바로 아래로 + const at = nowAt ? Date.parse(nowAt) : 0 + const nowSlot = (today.data?.slots ?? []).filter((x) => x.temp_c != null).reduce((a, b) => (!a || Math.abs(Date.parse(b.at) - at) < Math.abs(Date.parse(a.at) - at) ? b : a), undefined) + const raining = ['rain', 'snow', 'sleet'].includes(weatherOf(nowSlot)) || !!f?.hero?.will_rain_2h + const sunsetAt = posts.findIndex((p) => p.post_type === PostType.SUNSET) useEffect(() => { window.scrollTo({ top: 0 }) @@ -623,6 +622,17 @@ export function TodayPage() { [9, bands?.season?.length ? : null], ] + // 사람 글 묶음은 포스트 사이사이에 하나씩: 묶음·띠·단풍 카드가 이미 붙는 자리와 바로 앞 자리는 건너뛰어 가로 목록이 연달아 나오지 않게 + const spreadTopics = [TalkTopic.OUTFIT, ...(raining ? [] : [TalkTopic.RAIN]), ...(sunsetAt < 0 ? [TalkTopic.SKY] : []), ...(posts.length < 2 ? [TalkTopic.FOLIAGE] : [])].filter((tp) => groupOf(tp).length) + const taken = new Set([1, sunsetAt, ...bandAt.map(([at]) => at - 1)]) + const spreadAt = new Map() + let spreadN = 0 + for (let i = 0; i < posts.length && spreadN < spreadTopics.length; i++) { + if (taken.has(i) || spreadAt.has(i - 1)) continue + spreadAt.set(i, group(spreadTopics[spreadN++])) + } + const spreadLeft = spreadTopics.slice(spreadN).map((tp) => group(tp)) + return ( // 피드 칸은 전국 공통이라 지역이 바뀌어도 글 번호가 같다. 지역마다 새로 그려 넘긴 슬라이드·펼친 상태가 남지 않게 한다
@@ -631,6 +641,7 @@ export function TodayPage() { {mine.map((t) => ( setMine((m) => m.filter((x) => x.talk_id !== t.talk_id))} /> ))} + {raining && group(TalkTopic.RAIN)} {/* 실패 안내는 여기 한 번만, 각 카드 스켈레톤과 같은 크기로 */} {stories.some((g) => g.active) ? ( @@ -640,6 +651,7 @@ export function TodayPage() { ) : ( feed.refetch()} empty="오늘 계산된 각이 없어요." hold={} className="inset-x-3 top-3 bottom-1" /> )} +
{load === 'loading' && } @@ -650,14 +662,16 @@ export function TodayPage() { {posts.map((p, i) => ( + {i === sunsetAt && group(TalkTopic.SKY)} {i === 1 && } - {i > 0 && i % TALK_EVERY === 0 && talks[i / TALK_EVERY - 1] && } + {i === 1 && group(TalkTopic.FOLIAGE)} {bandAt.find(([at]) => at === i + 1)?.[1]} + {spreadAt.get(i)} ))} + {/* 글이 모자라 끼울 자리가 없던 묶음은 맨 뒤에 */} + {feed.isSuccess && spreadLeft} {feed.isSuccess && bandAt.filter(([at]) => at > posts.length).map(([at, node]) => {node})} - {load !== 'loading' && talks.slice(between).map((t) => )} -
) diff --git a/frontend/src/b/talk.tsx b/frontend/src/b/talk.tsx index e442d4c..4ba26cf 100644 --- a/frontend/src/b/talk.tsx +++ b/frontend/src/b/talk.tsx @@ -1,5 +1,6 @@ import { useMutation, useQueryClient } from '@tanstack/react-query' import { useEffect, useRef, useState, type ChangeEvent, type FormEvent } from 'react' +import { Link } from 'react-router' import { addTalkMutation, blockTalkAuthorMutation, @@ -9,16 +10,16 @@ import { unlikeTalkMutation, } from '../api/client/@tanstack/react-query.gen' import { uploadTalkImage } from '../api/client/sdk.gen' -import { TalkReport, type TalkData } from '../api/client/types.gen' +import { TalkReport, TalkTopic, type TalkData } from '../api/client/types.gen' import { API_BASE_URL } from '../api/setup' import { cx } from '../lib/utils' import { useAuth } from './authContext' import { ago, kst } from './lib' import { useRegion } from './regionContext' -import { useMyTalks } from './talkState' +import { topicName, TOPICS, useMyTalks } from './talkState' import { useSheet } from './sheetContext' import { HeartIcon } from './svg' -import { Avatar, TAP44 } from './ui' +import { Avatar, Rail, TAP44 } from './ui' const BODY_MAX = 100 const PHOTO_MAX = 10 * 1024 * 1024 @@ -30,6 +31,10 @@ const WRITE_ERRORS: Record = { INVALID_INPUT: '100자 안으로 써 주세요.', } +// 글이 이보다 적으면 '동네 사람들' 묶음 대신 첫 글 쓰기 카드 +const GROUP_MIN = 3 +const COMPOSE_ID = 'talk-compose' + const REASONS = [ [TalkReport.ABUSE, '욕설·비하'], [TalkReport.SPAM, '광고·도배'], @@ -45,7 +50,7 @@ function slotWord(iso: string) { function useRefreshTalks() { const queryClient = useQueryClient() - return () => queryClient.invalidateQueries({ predicate: (q) => ['listTalks', 'listMyTalks'].includes((q.queryKey[0] as { _id?: string } | undefined)?._id ?? '') }) + return () => queryClient.invalidateQueries({ predicate: (q) => ['listTalks', 'listMyTalks', 'talkGroups'].includes((q.queryKey[0] as { _id?: string } | undefined)?._id ?? '') }) } function Composer({ onDone }: { onDone?: (t: TalkData) => void }) { @@ -55,6 +60,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) { const refresh = useRefreshTalks() const add = useMutation(addTalkMutation()) const [text, setText] = useState('') + const [topic, setTopic] = useState(TalkTopic.LOCAL) const [error, setError] = useState(null) const [photo, setPhoto] = useState<{ file: File; src: string } | null>(null) const [uploading, setUploading] = useState(false) @@ -97,12 +103,13 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) { upload().then( (image) => add.mutate( - { body: { region_code: region.code, body, image } }, + { body: { region_code: region.code, body, image, topic } }, { onSuccess: (res) => { if (!res.result?.success) return setError(WRITE_ERRORS[res.result?.desc ?? ''] ?? '글을 올리지 못했어요. 다시 해 주세요.') setText('') setPhoto(null) + setTopic(TalkTopic.LOCAL) refresh() if (res.talk) onDone?.(res.talk) }, @@ -119,6 +126,7 @@ function Composer({ onDone }: { onDone?: (t: TalkData) => void }) { return (