DeveloperAcademy-POSTECH / DeveloperAcademy-POSTECH/MacC-Team-Vegeting
[FEAT]: 새로운 채팅시, collectionView의 inserItem을 활용
- Dominant language
- Swift
- Stars
- 5
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
## 💡 Issue
### 문제상황
1. 현재 새로운 채팅이 들어올때마다 scrolltem을 통해서 bottom으로 내려줄 때
- 원인 불명의 이슈로 마지막 셀의 시작 y index + estimatedSize만큼만 스크롤 되는 현상
- 이로인해 estimatedSize를 강제적으로 900이라는 큰 숫자를 줘서 해결
2. performBatchUpdates의 잘못된 사용
- 해당 함수를 collecitonView reloadData가 끝났을 때, 호출되어야 하는 함수로 오해
- 그로인해, scrollItem함수가 performBatchUpdates 클로저 내부에 존재
- 원래 사용용도는 collectionview의 insert, delete, reload, move등이 동시다발적으로 일어났을 때 한번에 처리할 수 있도록 하는 용도
3. 새로운 채팅이 들어올 때마다 전체 collectionView가 reload
- 이로인해 계속해서 reloadData가 발생
- performance에 bottleNeck으로 작용
### 해결책
1. performBatchUpdates의 올바른 사용
- 기존 새로운 채팅마다 reloadData하는 방식 삭제
- inserItem을 통해서 콜렉션뷰에 삽입하는 형태로 변경
- Apple Feedback Assistant에서도 지적한 사항(참고사항 인용문 참고)
## 📝 todo
- [ ] estimatedSize 원상복귀
- [ ] performBatchUpdate에 insertItem으로 변경
- [ ] viewWillAppear일때만, collectionView reloadData하도록 변경
## 참고한 코드 출처
- Apple Feedback Assistant
> After reviewing your feedback, we have some additional information for you, or some additional information, or action is necessary for this issue: While your idea in general is correct, performing layout work inside of a batch updates block is not correct. After calling reloadData(), immediately call layoutIfNeeded(), and then call scrollToItem(). Ideally, you would also not perform a reload data every time a new message arrives. Instead, consider inserting an item from within a batch updates block.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.