Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 위니피드, 마이피드 / 스크롤 위치 문제, 좋아요 ui 반영문제 해결 #159

Merged
merged 10 commits into from
Aug 27, 2023

Conversation

sxunea
Copy link
Contributor

@sxunea sxunea commented Aug 26, 2023

📝 Work Description

  • 스크롤 위치 문제 해결
  • 상세페이지로 두세번 이상 왔다갔다하고 좋아요를 누르면 서버통신은 되지만 이를 observe하지못하는 문제 해결

📣 To Reviewers

일요일 저녁전까지 부탁드립니다 ~
자세한 원인이 궁금하면 아래 트러블슈팅 기록을 참고해주세용

@sxunea sxunea added fix 💥 버그 및 오류 해결 혜선 🐱 labels Aug 26, 2023
@sxunea sxunea added this to the 기능 구현 ✨ milestone Aug 26, 2023
@sxunea sxunea self-assigned this Aug 26, 2023
@sxunea
Copy link
Contributor Author

sxunea commented Aug 26, 2023

📝 TroubleShooting

  • 스크롤 위치 문제

    • 원인 : 2페이지 이상에 있는 피드의 상세페이지 갔다가 위니피드/마이피드 돌아올 시 해당페이지를 다시 불러오게 되면서 2페이지의 첫번째아이템으로 사용자의 스크롤 위치가 초기화됨
    • 해결 : 상세페이지로 갈 시 해당아이템의 인덱스를 저장해두었다. 또, 올바른 위치로 조정해주는 작업이 피드가 다시 불러와지고 수행되어야하므로, initGetFeedStateObserver에서 로딩상태를 따로 분기처리해 loading 완료 시 스크롤 위치가 재조정 되도록 하여 해결
  • 상세페이지로 두세번 이상 왔다갔다하고 좋아요를 누르면 서버통신은 되지만 observe하지못해 ui 반영안되는 문제

    • 원인 : getWineyFeedListState의 초기 상태와 서버 통신 시작 시점의 상태가 같아서 생긴 문제이다 . 처음 정의할때도 uiState.Loading이고 서버통신을 할때도 그 상태에서 success/failure로 갈리므로 그 값이 같다. 이때, 이전 값과 새로운 값이 동일한 경우 값을 StateFlow는 이를 관찰하지않아서 initPostLikeStateObserver가 실행되지 않았다.
    • 해결 : viewmodel에서 getWineyFeedListState를 처음 정의할땐 Empty, 시작할때 Loading으로 변경하여 해결

Copy link
Member

@leeeha leeeha left a comment

Choose a reason for hiding this comment

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

리뷰가 좀 늦어서 미안합니닷,, 중요한 이슈들 해결해서 넘 다행이다!! 고생했어 진짜 👍👍💚

is LoadState.Error -> {
Timber.tag("failure").e(MSG_WINEYFEED_ERROR)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

오홍 페이징에서 LoadState 라는 걸 제공하는군요!! 페이징에 대해 저도 더 알아보고 싶네용 👀

@@ -309,6 +337,8 @@ class WineyFeedFragment :
}

private fun navigateToDetail(wineyFeed: WineyFeed) {
selectedItemIndex = wineyFeedAdapter.snapshot().indexOf(wineyFeed)
selectedScrollPosition = binding.rvWineyfeedPost.layoutManager?.onSaveInstanceState()
Copy link
Member

Choose a reason for hiding this comment

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

오오 스크롤 위치 저장하고 다시 불러오는 식으로 될 거 같았는데 결국 해냈네!! 갓-혜선 최고 💚

notifyItemChanged(index)
}
}
}
Copy link
Member

@leeeha leeeha Aug 27, 2023

Choose a reason for hiding this comment

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

페이징 쓰더라도 일부 아이템만 변경할 수 있네요?! ㅎㅎ

저번에 snapshot().items 로 리스트 얻어올 수 있다고 리뷰 달았던 거 같은데, 전체를 리프레시 하지 않고 일부 아이템만 갱신하는 방법 찾아서 넘 다행이에용 💖

Copy link
Contributor Author

@sxunea sxunea Aug 27, 2023

Choose a reason for hiding this comment

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

items까지만 가능하고 안의 index까지는 접근할수 있을지 몰랐어요 ㅎㅎㅎ 페이징 욕했던날들 반성 중 ... 😻

if (animator is SimpleItemAnimator) {
animator.supportsChangeAnimations = false
}
}
Copy link
Member

Choose a reason for hiding this comment

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

깜박거림 이슈 해결~!~! 굿굿

@@ -29,7 +29,7 @@ class MyFeedViewModel @Inject constructor(
val getMyFeedListState: StateFlow<UiState<PagingData<WineyFeed>>> =
_getMyFeedListState.asStateFlow()

private val _postMyFeedLikeState = MutableStateFlow<UiState<Like>>(UiState.Loading)
private val _postMyFeedLikeState = MutableStateFlow<UiState<Like>>(UiState.Empty)
Copy link
Member

Choose a reason for hiding this comment

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

저도 위니 업로드에서 UiState 초기값을 로딩으로 잘못 줘서, 업로드가 되지 않는 이슈가 있었는데

여기도 비슷한 원인이었네요! 트러블 슈팅 굿굿 👍👍

Copy link
Contributor

@Sangwook123 Sangwook123 left a comment

Choose a reason for hiding this comment

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

👍👍👍👍👍

@sxunea sxunea merged commit ecabba4 into develop Aug 27, 2023
1 check passed
@sxunea sxunea deleted the fix/feed branch August 31, 2023 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 💥 버그 및 오류 해결 혜선 🐱
Projects
Status: Done
3 participants