feat: 앱 동네 이야기 — /talk 주제별 글·내 글, 오늘 피드 쓰기 칸과 포스트 두 장마다 사람 글, 사진 올리기(expo-image-picker, 카메라·마이크 권한 없음), 이야기 댓글·좋아요·신고·안 보기·지우기, 내 정보 내 글. 기념일 목록을 shared로 (GA talk_post·talk_comment·feed_item_view, like·report·block talk)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
skkimandClaude committed 2026-11-04 17:35:23 +09:00
1 parent e40a9a0539
commit c15f045c64
16 files changed
+941 -300

No files matched your search

+3 -1
View File
@@ -2,7 +2,9 @@ import { createContext, use } from 'react';
import type { WeatherWhyPayload } from '@/components/sheets/weather-why';
type CommentsState = { type: 'comments'; postId: number; draft?: string };
/** 댓글이 달린 곳: 운영 포스트 또는 사람 글 */
export type CommentTarget = { postId: number } | { talkId: number };
type CommentsState = { type: 'comments'; draft?: string } & CommentTarget;
export type SheetState =
| { type: 'gak'; indexId: number }
+75
View File
@@ -0,0 +1,75 @@
import { listMyTalksInfiniteOptions, listTalksInfiniteOptions } 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 { HOLIDAYS, holidayOn } from '@nalssigak/shared/lib/holiday';
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
import { useRegion } from '@/lib/region';
import { apiUri } from '@/lib/site';
// 글 주제와 이름 (웹 talkState.ts)
export const TOPICS = [
[TalkTopic.LOCAL, '동네 이야기'],
[TalkTopic.SKY, '하늘·노을'],
[TalkTopic.RAIN, '비·눈'],
[TalkTopic.FOLIAGE, '단풍·꽃'],
[TalkTopic.OUTFIT, '오늘 옷차림'],
...HOLIDAYS.map((h) => [h.topic, h.name] as const),
] as const;
export const topicName = (t?: number) => TOPICS.find(([k]) => k === t)?.[1] ?? '동네 이야기';
/** 지금 고를 수 있는 주제: 기념일 주제는 그 기간에만 */
export function openTopics() {
const on = holidayOn()?.topic;
return TOPICS.filter(([k]) => !HOLIDAYS.some((h) => h.topic === k) || k === on);
}
/** 주제별 글 페이지 목록 (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,
refetch: list.refetch,
refetching: list.isRefetching,
};
}
/** 내가 쓴 글 (최신순) */
export function useMyTalks(enabled = true) {
const list = useInfiniteQuery({
...listMyTalksInfiniteOptions(),
enabled,
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 useRefreshTalks() {
const queryClient = useQueryClient();
return () => queryClient.invalidateQueries({ predicate: (q) => ['listTalks', 'listMyTalks'].includes((q.queryKey[0] as { _id?: string } | undefined)?._id ?? '') });
}
/** 쓴 시각을 시간대로만: 정확한 시각은 동선이 드러나서 뭉갠다 */
function slotWord(iso: string) {
const h = kst(iso).h;
return h < 6 ? '새벽' : h < 10 ? '아침' : h < 17 ? '낮' : h < 21 ? '저녁' : '밤';
}
export const talkMeta = (t: TalkData) => [t.region_name, slotWord(t.created_at), t.weather, t.topic && t.topic !== TalkTopic.LOCAL ? topicName(t.topic) : null].filter(Boolean).join(' · ');
/** 올린 사진은 API 서버 경로(/v1/talk/image/...) */
export const talkImage = (t: TalkData) => (t.image ? apiUri(t.image) : undefined);