Skip to content

refactor: 네트워크 요청 최적화 및 Prefetch 추가 (#313)#316

Merged
PeraSite merged 16 commits intodevelopfrom
refactor/reduce-network-call-313
Feb 22, 2026
Merged

refactor: 네트워크 요청 최적화 및 Prefetch 추가 (#313)#316
PeraSite merged 16 commits intodevelopfrom
refactor/reduce-network-call-313

Conversation

@PeraSite
Copy link
Copy Markdown
Collaborator

📌 관련 이슈

✨ 변경 내용

  • 영상 목록 쿼리 키를 queryKeys.videos.listPrefix/list(projectId, params)로 표준화하고, 업로드/수정/삭제 후 invalidation 대상을 정리했습니다.
  • 프로젝트 진입 시 slides/project scripts prefetch를 추가하고(useProjectEntryPrefetch), 대본 조회 경로를 캐시 우선으로 통합해 중복 요청을 줄였습니다.
  • useSlides를 옵션 기반으로 개편해 기본 non-polling으로 전환하고, SlidePage만 15초 라이브 동기화를 유지했습니다.
  • 공유(Feedback) 댓글 조회를 useSharedComments 단일 소스로 통합하고, 타임라인/상세 API 조건부 호출로 불필요 요청을 제거했습니다.
  • 대본 UI를 정리했습니다: 대본 하단 예상 시간 배지를 floating 형태로 변경, 읽기 속도 슬라이더 테두리 톤 조정, /share 비디오 대본 active 표시 교정.
  • 회귀 방지 테스트를 추가했습니다 (requestOptimizationRegression, useSlides, useFeedbackVideo, queryKeys).

💡 참고 사항

  • 검증
    • npm run type-check
    • npm run test -- src/api/queryClient.test.ts src/hooks/queries/useSlides.test.tsx src/pages/feedback/useFeedbackVideo.test.tsx src/pages/requestOptimizationRegression.test.ts

@github-actions github-actions bot added component 컴포넌트 관련 변경 page 페이지 관련 변경 hooks 커스텀 훅 변경 labels Feb 22, 2026
@PeraSite PeraSite requested a review from Copilot February 22, 2026 03:11
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @PeraSite, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 Pull Request는 애플리케이션의 전반적인 성능과 사용자 경험을 향상시키기 위해 API 호출을 최적화하고 데이터 캐싱 전략을 개선하는 데 중점을 둡니다. 특히, 영상 목록 관리, 슬라이드 대본 로딩, 공유 피드백 댓글 처리 방식에서 불필요한 네트워크 요청을 줄이고 데이터 동기화 로직을 효율화했습니다. 또한, 사용자 인터페이스의 시각적 개선과 함께 중요한 기능에 대한 회귀 방지 테스트를 도입하여 코드의 안정성을 강화했습니다.

Highlights

  • API 호출 최적화: 영상 목록 쿼리 키를 표준화하고, 업로드/수정/삭제 후 캐시 무효화 대상을 정리했습니다.
  • 대본 캐시/프리패치: 프로젝트 진입 시 슬라이드 및 프로젝트 대본을 미리 가져오고, 대본 조회 경로를 캐시 우선으로 통합하여 중복 요청을 줄였습니다.
  • useSlides 개편: useSlides 훅을 옵션 기반으로 변경하여 기본적으로 폴링을 비활성화하고, SlidePage에서만 15초 라이브 동기화를 유지하도록 했습니다.
  • 공유 댓글 통합: 공유(Feedback) 댓글 조회를 useSharedComments 훅으로 통합하고, 타임라인/상세 API 조건부 호출로 불필요한 요청을 제거했습니다.
  • 대본 UI 개선: 대본 하단 예상 시간 배지를 플로팅 형태로 변경하고, 읽기 속도 슬라이더 테두리 톤을 조정했으며, /share 비디오 대본의 활성 표시를 교정했습니다.
  • 회귀 방지 테스트 추가: API 최적화 및 훅 관련 회귀 방지 테스트를 추가하여 변경 사항의 안정성을 확보했습니다.
Changelog
  • src/api/queryClient.test.ts
    • 영상 목록 쿼리 키 빌드 로직에 대한 테스트를 추가했습니다.
  • src/api/queryClient.ts
    • 스크립트 쿼리 키에 'projects' 접두사를 추가했습니다.
    • 영상 목록 쿼리 키를 파라미터와 접두사를 지원하도록 업데이트했습니다.
  • src/components/common/layout/Gnb.tsx
    • useProjectEntryPrefetch 훅을 통합하여 프로젝트 진입 시 데이터를 미리 가져오도록 했습니다.
  • src/components/slide/SlideWorkspace.tsx
    • 스크립트 로딩 로직을 업데이트하여 캐시된 프로젝트 스크립트를 우선 사용하고, 개별 스크립트 페치를 조건부로 수행하도록 변경했습니다.
  • src/components/slide/script/ScriptBoxContent.tsx
    • 예상 시간 배지의 스타일과 위치를 플로팅 형태로 변경했습니다.
  • src/components/slide/script/ScriptReadingSpeedModal.tsx
    • 읽기 속도 슬라이더의 테두리 스타일을 업데이트했습니다.
  • src/components/video/RecordingSection.tsx
    • 스크립트 페칭을 위해 useScript를 useProjectScripts로 교체했습니다.
    • 슬라이드 목록에 스크립트 데이터를 추가했습니다.
    • 스크립트 표시 로직을 업데이트했습니다.
  • src/hooks/queries/useProjectEntryPrefetch.ts
    • 프로젝트 슬라이드와 스크립트를 미리 가져오는 새로운 훅을 추가했습니다.
  • src/hooks/queries/useScript.ts
    • useScript 및 useProjectScripts 훅에 'enabled' 및 'staleTime' 옵션을 추가했습니다.
    • useUpdateScript가 캐시된 슬라이드 및 프로젝트 스크립트 데이터를 업데이트하도록 수정했습니다.
  • src/hooks/queries/useSharedComments.ts
    • useSharedComments 훅에 'enabled' 및 'staleTime' 옵션을 추가했습니다.
  • src/hooks/queries/useSlides.test.tsx
    • useSlides 훅에 대한 새로운 테스트 파일을 추가했습니다.
  • src/hooks/queries/useSlides.ts
    • useSlides 훅을 'enabled', 'liveSync', 'pollingIntervalMs' 옵션을 지원하도록 리팩토링하여 기본적으로 폴링을 비활성화했습니다.
  • src/hooks/useInsightPageModel.ts
    • useSlides 호출에서 라이브 동기화를 비활성화했습니다.
  • src/hooks/usePresentationVideos.ts
    • usePresentationVideos 훅이 표준화된 queryKeys.videos.list를 정규화된 파라미터와 함께 사용하도록 업데이트했습니다.
  • src/hooks/useScriptBulkEdit.ts
    • useScriptBulkEdit 훅에서 useProjectScripts를 기본적으로 비활성화하고, queryClient.ensureQueryData를 사용하여 데이터를 가져오도록 변경했습니다.
    • refetchProjectScripts를 제거했습니다.
  • src/pages/FeedbackVideoPage.tsx
    • ScriptSection 컴포넌트에서 'variant="inverted"' 속성을 제거했습니다.
  • src/pages/SlidePage.tsx
    • useSlides 훅을 15초 폴링 간격으로 라이브 동기화하도록 구성했습니다.
  • src/pages/VideoDetailPage.tsx
    • 스크립트 페칭을 위해 직접적인 getScript 호출을 useProjectScripts로 대체했습니다.
    • 캐시된 프로젝트 스크립트를 사용하도록 스크립트 로딩 로직을 업데이트했습니다.
  • src/pages/VideoListPage.tsx
    • 영상 목록 무효화 로직을 queryKeys.videos.listPrefix를 사용하도록 업데이트했습니다.
    • 영상 제목 변경 및 삭제 시 캐시를 직접 업데이트하도록 추가했습니다.
  • src/pages/VideoRecordPage.tsx
    • useProjectEntryPrefetch를 통합했습니다.
    • 영상 목록 무효화를 queryKeys.videos.listPrefix를 사용하도록 업데이트했습니다.
  • src/pages/feedback/useFeedbackSlide.ts
    • 직접적인 getSharedComments 호출을 useSharedComments 훅으로 대체했습니다.
    • invalidateSharedComments를 사용하여 댓글 처리를 업데이트했습니다.
  • src/pages/feedback/useFeedbackVideo.test.tsx
    • useFeedbackVideo 훅에 대한 새로운 테스트 파일을 추가했습니다.
  • src/pages/feedback/useFeedbackVideo.ts
    • 직접적인 getSharedComments 호출을 useSharedComments 훅으로 대체했습니다.
    • 영상 상세/슬라이드 API 호출을 최적화했습니다.
    • invalidateSharedComments를 사용하여 댓글 처리를 업데이트했습니다.
  • src/pages/requestOptimizationRegression.test.ts
    • API 최적화 변경 사항이 유지되도록 새로운 회귀 테스트 파일을 추가했습니다.
Activity
  • npm run type-check를 통해 타입 검증을 수행했습니다.
  • src/api/queryClient.test.ts, src/hooks/queries/useSlides.test.tsx, src/pages/feedback/useFeedbackVideo.test.tsx, src/pages/requestOptimizationRegression.test.ts 파일에 대한 단위 테스트를 실행했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR is an important refactoring focused on optimizing API calls and improving cache strategy, including the introduction of the useProjectEntryPrefetch hook, addressing N+1 issues, and enhancing UI responsiveness with optimistic updates. However, instances were identified where untrusted URL parameters (like shareToken and sessionId) are used in API requests without proper URL encoding. This introduces risks of path traversal and query parameter injection. It is recommended to consistently use encodeURIComponent() for such variables interpolated into URL paths or query strings. Overall, the code quality is very high, and the changes are expected to significantly enhance application performance and user experience, despite a few minor maintainability improvement suggestions.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

이 PR은 API 과호출을 줄이고 대본 캐시/프리패치를 최적화하여 사용자 경험을 개선하는 리팩토링 작업입니다. 프로젝트 진입 시 슬라이드와 대본을 미리 적재하고, 불필요한 폴링을 제거하며, 영상 목록의 쿼리 키를 표준화하여 캐시 관리를 개선했습니다. 또한 공유 피드백 댓글 조회를 단일 소스로 통합하고, 조건부 API 호출로 중복 요청을 제거했습니다.

Changes:

  • 영상 목록 쿼리 키를 listPrefix/list(projectId, params) 구조로 표준화하고 업데이트/삭제 시 optimistic updates 추가
  • useProjectEntryPrefetch 훅으로 프로젝트 진입 시 슬라이드/대본 prefetch 구현
  • useSlides 기본 폴링 비활성화 및 liveSync 옵션 추가 (SlidePage만 15초 폴링 유지)
  • 공유 피드백 댓글을 useSharedComments 단일 소스로 통합하고 타임라인/상세 API 조건부 호출
  • 대본 UI 개선: floating 예상 시간 배지, 읽기 속도 슬라이더 테두리 스타일 조정
  • 회귀 방지 테스트 추가

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/api/queryClient.ts 영상 쿼리 키를 listPrefix/list 계층 구조로 변경, scripts 쿼리 키에 projects() 추가
src/api/queryClient.test.ts 영상 쿼리 키 빌드 테스트 추가
src/hooks/queries/useSlides.ts enabled, liveSync, pollingIntervalMs 옵션 추가하여 폴링 제어
src/hooks/queries/useSlides.test.tsx useSlides 옵션 동작 테스트 추가
src/hooks/queries/useSharedComments.ts enabled, staleTime 옵션 추가
src/hooks/queries/useScript.ts enabled, staleTime 옵션 추가 및 캐시 업데이트 로직 추가
src/hooks/queries/useProjectEntryPrefetch.ts 프로젝트 진입 시 슬라이드/대본 prefetch 훅 구현
src/hooks/useScriptBulkEdit.ts ensureQueryData로 대본 조회 최적화, enabled: false로 자동 재요청 방지
src/hooks/usePresentationVideos.ts 표준화된 쿼리 키 사용
src/hooks/useInsightPageModel.ts useSlides liveSync: false 설정
src/pages/SlidePage.tsx useSlides liveSync: true, 15초 폴링 설정
src/pages/VideoDetailPage.tsx 개별 getScript 호출 제거, useProjectScripts로 일괄 조회
src/pages/VideoRecordPage.tsx prefetch 훅 추가, listPrefix 쿼리 키 사용
src/pages/VideoListPage.tsx optimistic updates 구현, listPrefix 쿼리 키 사용
src/pages/FeedbackVideoPage.tsx variant="inverted" 제거
src/pages/feedback/useFeedbackVideo.ts useSharedComments 통합, 조건부 API 호출, invalidateQueries 패턴 적용
src/pages/feedback/useFeedbackVideo.test.tsx API 조건부 호출 및 댓글 invalidate 테스트 추가
src/pages/feedback/useFeedbackSlide.ts useSharedComments 통합, invalidateQueries 패턴 적용
src/pages/requestOptimizationRegression.test.ts API 과호출 회귀 방지 테스트 추가
src/components/common/layout/Gnb.tsx prefetch 훅 추가
src/components/video/RecordingSection.tsx useProjectScripts로 대본 일괄 조회, 개별 useScript 제거
src/components/slide/SlideWorkspace.tsx 프로젝트 대본 우선 조회 후 개별 대본 fallback 구조
src/components/slide/script/ScriptBoxContent.tsx floating 예상 시간 배지 스타일 변경, textarea 패딩 조정
src/components/slide/script/ScriptReadingSpeedModal.tsx 슬라이더 테두리 및 스타일 개선

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@PeraSite PeraSite changed the title refactor: API 과호출 줄이고 대본 캐시/프리패치 최적화 (#313) refactor: 네트워크 요청 최적화 및 Prefetch 추가 (#313) Feb 22, 2026
@PeraSite PeraSite merged commit 05b391d into develop Feb 22, 2026
8 checks passed
@PeraSite PeraSite deleted the refactor/reduce-network-call-313 branch February 22, 2026 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component 컴포넌트 관련 변경 hooks 커스텀 훅 변경 page 페이지 관련 변경

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: 대본, 제목 등 Prefetch 추가, 불필요한 서버 요청 제거

2 participants