Skip to content

fix: 토글에 따른 사진 선택 로직 개선#199

Merged
dasosann merged 1 commit intomainfrom
fix/toggle
Mar 26, 2026
Merged

fix: 토글에 따른 사진 선택 로직 개선#199
dasosann merged 1 commit intomainfrom
fix/toggle

Conversation

@dasosann
Copy link
Copy Markdown
Contributor

요약

구현 사항

  • 토글에 따른 사진 선택 로직 개선
  • [ ]
  • [ ]
  • [ ]

📸 스크린샷

Need Review

  • ~ 부분 이렇게 구현했어요, 피드백 부탁해요!

Reference

📜 리뷰 규칙

Reviewer는 아래 P5 Rule을 참고하여 리뷰를 진행합니다.
P5 Rule을 통해 Reviewer는 Reviewee에게 리뷰의 의도를 보다 정확히 전달할 수 있습니다.

  • P1: 꼭 반영해주세요 (Comment)
  • P2: 적극적으로 고려해주세요 (Comment)
  • P3: 웬만하면 반영해 주세요 (Comment)
  • P4: 반영해도 좋고 넘어가도 좋습니다 (Approve)
  • P5: 그냥 사소한 의견입니다 (Approve)

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
fe Error Error Mar 26, 2026 7:32am

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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!

이 PR은 앨범 상세 화면에서 사진 선택 로직을 개선하여 사용자 경험을 향상시킵니다. 특히, includeMyPhotos 토글과 같은 필터 변경 시 선택 상태의 일관성을 유지하고, '전체 선택' 버튼의 동작을 보다 직관적으로 만들었습니다.

Highlights

  • 선택 로직 개선: isAllSelected 대신 hasAnySelected 변수를 도입하여 사진 선택 상태를 보다 유연하게 관리하도록 로직을 개선했습니다.
  • 전체 선택/해제 동작 변경: handleToggleSelectAll 함수가 '모든 사진이 선택되었는지' 여부가 아닌 '하나라도 선택된 사진이 있는지' 여부에 따라 전체 선택 해제 동작을 수행하도록 변경하여 사용자 경험을 향상시켰습니다.
  • 필터링된 사진 자동 제거: includeMyPhotos 토글과 같은 필터 변경 시, 더 이상 선택 불가능해진 사진들을 selectedPhotos 목록에서 자동으로 제거하는 useEffect 훅을 추가하여 선택 상태의 일관성을 유지했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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.

@dasosann dasosann merged commit 5c39752 into main Mar 26, 2026
4 checks passed
@dasosann dasosann deleted the fix/toggle branch March 26, 2026 07:11
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 pull request refactors the photo selection logic in PhotoList.tsx by introducing a hasAnySelected state and modifying the 'Select All' button's behavior. It also adds a useEffect hook to automatically filter out selected photos that are no longer selectable. Feedback includes a concern that the updated 'Select All' button logic might negatively impact user experience by preventing users from selecting all photos if some are already selected, suggesting a three-state handling for selection. Additionally, it's recommended to memoize the selectableIds calculation within the new useEffect hook using useMemo for performance optimization and improved code readability.


const handleToggleSelectAll = () => {
if (isAllSelected) {
if (hasAnySelected) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

isAllSelected에서 hasAnySelected로 조건을 변경하면서, 일부 사진만 선택된 상태에서 전체를 선택하는 기능이 사라졌습니다. 현재 로직에서는 일부라도 선택되어 있으면 "전체 선택 취소"만 가능하여, 사용자가 전체 선택을 하려면 먼저 모든 선택을 해제해야 합니다. 이는 사용자 경험을 저해할 수 있습니다.

예를 들어, 100장 중 99장을 선택한 사용자가 나머지 한 장을 선택하기 위해 "전체 선택"을 누르고 싶을 수 있지만, 현재는 불가능합니다.

세 가지 상태(선택 없음, 일부 선택, 전체 선택)를 구분하여 처리하는 것을 고려해보세요. 예를 들어, 일부만 선택된 상태에서는 여전히 "전체 선택" 버튼을 표시하여 사용자가 나머지 항목을 쉽게 선택할 수 있도록 할 수 있습니다.

Comment on lines +211 to +222
useEffect(() => {
if (mode !== 'select') return;

const selectableIds = new Set(selectablePhotos.map((p) => p.photoId));
const currentSelected = useSelectedPhotosStore.getState().selectedPhotos;
const filtered = currentSelected.filter((p) => selectableIds.has(p.id));

if (filtered.length !== currentSelected.length) {
setSelectedPhotos(filtered);
setIsSelectAllMode(false);
}
}, [mode, selectablePhotos, setSelectedPhotos]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

useEffect 내에서 selectablePhotos가 변경될 때마다 new Set(selectablePhotos.map(...))을 통해 selectableIds를 생성하고 있습니다. selectablePhotos가 큰 배열일 경우 성능에 미미한 영향을 줄 수 있습니다.

이 계산은 useMemo를 사용하여 컴포넌트의 최상위 레벨에서 memoization하는 것을 고려해볼 수 있습니다. 이렇게 하면 계산 로직과 부수 효과(side effect) 로직이 분리되어 코드 가독성이 향상되고, 불필요한 재계산을 방지할 수 있습니다.

const selectableIds = useMemo(
  () => new Set(selectablePhotos.map((p) => p.photoId)),
  [selectablePhotos],
);

useEffect(() => {
  if (mode !== 'select') return;

  const currentSelected = useSelectedPhotosStore.getState().selectedPhotos;
  const filtered = currentSelected.filter((p) => selectableIds.has(p.id));

  if (filtered.length !== currentSelected.length) {
    setSelectedPhotos(filtered);
    setIsSelectAllMode(false);
  }
}, [mode, selectableIds, setSelectedPhotos]);

위와 같이 수정하면 useEffect의 의존성이 더 명확해지고 코드가 더 효율적으로 됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant