Skip to content

Conversation

@czmcm5
Copy link
Contributor

@czmcm5 czmcm5 commented Jun 26, 2025

개요

비로그인 시 좋아요 버튼을 누르면 좋아요가 등록되지 않아도 활성화 되는 에러를 수정하였습니다. 적고보니까 fix가 맞는걸지도..
공유하기 버튼을 누르면 현재 url이 복사 되도록 하였습니다.

변경 사항

  • 새로운 기능 추가
  • 버그 수정
  • 리팩토링
  • 문서 수정

구현 내용

  • useLike 개선
    • 인자로 넘겨주는 useParams()를 훅 내부에 선언
    • 좋아요 /좋아요 취소 함수 하나로 통합
    • 이모지를 눌러야 실행되도록 되어있길래 수정 .. 어쩐지 잘 안눌리더라고요 😓
  • 현재 url 복사하기 함수 추가

개발 후기 및 개선사항

이번 작업에서 배운 점

  • (없다면 패스)

어려웠던 점 / 에로사항

  • (없다면 패스)

다음에 개선하고 싶은 점

  • (없다면 패스)

팀원들과 공유하고 싶은 팁

  • (없다면 패스)

@vercel
Copy link

vercel bot commented Jun 26, 2025

@czmcm5 is attempting to deploy a commit to the tkyoun0421's projects Team on Vercel.

A member of the Team first needs to authorize it.

@tkyoun0421 tkyoun0421 added type: bug 버그 수정 type: refactor 코드 리팩토링 labels Jun 26, 2025
@vercel
Copy link

vercel bot commented Jun 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
project-jam ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2025 3:17am

Copy link
Contributor

@tkyoun0421 tkyoun0421 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 👍 👍 👍

Comment on lines +21 to +24
navigator.clipboard
.writeText(window.location.href)
.then(() => alert("URL이 복사되었습니다."))
.catch(() => alert("복사 실패"));
Copy link
Contributor

Choose a reason for hiding this comment

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

좋은 웹 API네요 또 하나 배워갑니다 :)
감사합니다 🙇

Comment on lines +36 to +42
if (!isLike) {
setIsLike(true);
updateLike(projectID);
} else {
setIsLike(false);
updateUnLike(projectID);
}
Copy link
Contributor

@tkyoun0421 tkyoun0421 Jun 26, 2025

Choose a reason for hiding this comment

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

비슷한 로직인 것 같아서 하나의 함수에서 관리하는 게 좋을 것 같다고 생각이 들어서 고민해보다가
근데 또 그렇게 생각해보니 복잡도가 좀 더 올라가는 부분이 있는 것 같아서..
어렵네요 개발 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

그쵸 ㅠㅠ api 부터 합칠까 고민했는데
넣고 빼는 행위 따라서 구분하는게 추후에 알아보기 더 쉬울거같아서 결국 나누었습니다😇

const { mutate: updateUnLike, isPending: unLikePending } = useProjectUnLike();

const initLike = user && likedUsers.includes(user.uid);
const [isLike, setIsLike] = useState(initLike || false);
Copy link
Contributor

Choose a reason for hiding this comment

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

현재 isLike 상태를 useState로만 관리하고 있는데,
유저 프로필에서 프로젝트 리스트 삭제 기능을 추가하면서 관심/좋아요 리스트를 전역상태 관리로 바꿨는데
프로필에서 관심 프로젝트를 삭제하면 디테일 페이지의 UI와 상태가 불일치 할 수도? 있을 것 같아요🥲

Copy link
Contributor Author

Choose a reason for hiding this comment

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

관심/좋아요 리스트를 전역상태로 바꿧다는 말은 api 호출로 db값을 수정하지않는다는 말씀이신가요 ?
상세페이지의 좋아요 여부 체크는 게시글(projects 컬렉션)에 등록된 좋아요한 유저 목록을 api로 불러와 현재 로그인 한 사용자의 id와 비교하여 보여주므로 프로필의 전역상태와는 무관할 것 같습니다 😀

Copy link
Contributor

Choose a reason for hiding this comment

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

엇 아니요 ! 전역 상태만 바꾸는 게 아니라, 반드시 API로 DB(파이어베이스) 값을 먼저 수정하고,
그 결과를 전역 상태에 반영해서 UI를 동기화한다는 말이었어요 !
상세페이지와 프로필 등 여러 곳에서 관심/좋아요 상태가 항상 일치하려면,
DB와 전역 상태를 항상 동기화하는 구조가 안전하지 않을까 생각합니다 !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아하 네~
상세 페이지에서는 항상 최신 상태의 db값을 들고오며 user 프로필에서 uid 값 이외엔 사용하지 않으니 수정하지 않아도 괜찮을 것 같습니다 😉

Copy link
Contributor

@namee-h namee-h left a comment

Choose a reason for hiding this comment

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

고생하셧어욥! 👏🏻

@tkyoun0421 tkyoun0421 merged commit bb1419c into amicable-development-center:develop Jun 27, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug 버그 수정 type: refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants