feat : BBS 게시판 목록 무한 스크롤 및 스크롤 위치 복원
SpecialSource Frontend (React) CD / deploy (push) Successful in 12s

- 목록 끝이 보이면 다음 페이지(30건)를 불러와 이어 붙임 (IntersectionObserver)
- 글 읽기에서 돌아오면 불러온 목록과 스크롤 위치를 그대로 유지
- 다음 페이지 중복 요청·실패 시 무한 재시도 방지

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
headporterandClaude Opus 5.5 committed 2026-11-25 15:32:50 +09:00
1 parent 94d7bd3409
commit d94aaa6f0a
5 files changed
+72 -13

No files matched your search

+9 -2
View File
@@ -1,6 +1,6 @@
import { AuthError } from "../api";
import { MENU } from "../constants";
import type { BbsState, MenuItem, Nav } from "../types";
import type { BbsState, Feed, MenuItem, Nav } from "../types";
export const initialState: BbsState = {
screen: "main",
@@ -31,7 +31,14 @@ function findMenu(raw: string): MenuItem | undefined {
}
/** 클릭/키보드 입력이 모두 거치는 단일 명령 처리기 (순수 함수 → useReducer reducer로 사용) */
export function execute(prev: BbsState, input: string | Nav | Partial<BbsState>): BbsState {
export function execute(prev: BbsState, input: string | Nav | Partial<BbsState> | { more: Feed }): BbsState {
if (typeof input !== "string" && "more" in input) {
// 무한 스크롤 다음 페이지: 지금 목록의 바로 다음 페이지일 때만 이어 붙임 (그 사이 탭을 바꿨거나 새로고침했으면 버림)
const { more } = input;
const f = prev.feed;
if (!f || f.kind !== more.kind || f.board !== more.board || more.page !== f.page + 1) return prev;
return { ...prev, feed: { ...more, posts: [...f.posts, ...more.posts] } };
}
if (typeof input !== "string") return { ...prev, error: null, ...input }; // 화면 복원, 로그인, 목록 도착, 오류
const raw = input.trim();
if (!raw) return prev;