1
0
şunun yansıması https://github.com/KokaKiwi/BarInsta eşitlendi 2025-07-05 10:52:01 +00:00

fix follower comparison issues

Bu işleme şunda yer alıyor:
Austin Huang 2021-07-24 10:28:32 -04:00
ebeveyn 52d53c5ad1
işleme 9358309c89
Veri tabanında bu imza için bilinen anahtar bulunamadı
GPG Anahtar Kimliği: 84C23AA04587A91F
2 değiştirilmiş dosya ile 11 ekleme ve 13 silme

Dosyayı Görüntüle

@ -153,14 +153,18 @@ class FollowViewerFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener {
override fun onQueryTextChange(query: String): Boolean { override fun onQueryTextChange(query: String): Boolean {
if (query.isEmpty()) { if (query.isEmpty()) {
if (!isCompare && searching) { if (!isCompare && searching) {
searching = false
viewModel.setQuery(null, isFollowersList) viewModel.setQuery(null, isFollowersList)
viewModel.getSearch().removeObservers(viewLifecycleOwner) viewModel.getSearch().removeObservers(viewLifecycleOwner)
viewModel.getList(isFollowersList).observe(viewLifecycleOwner) { viewModel.getList(isFollowersList).observe(viewLifecycleOwner) {
refreshAdapter(it, null, null, null) refreshAdapter(it, null, null, null)
} }
return true
}
if (isCompare && searching) {
adapter!!.filter.filter("")
return true
} }
searching = false
return true
} }
searching = true searching = true
if (isCompare && adapter != null) { if (isCompare && adapter != null) {

Dosyayı Görüntüle

@ -45,21 +45,15 @@ class FollowViewModel : ViewModel() {
if (it.first && it.second) { if (it.first && it.second) {
val followersList = followers.value!! val followersList = followers.value!!
val followingList = followings.value!! val followingList = followings.value!!
val allUsers: MutableList<User> = mutableListOf()
allUsers.addAll(followersList)
allUsers.addAll(followingList)
val followersMap = followersList.groupBy { it.pk }
val followingMap = followingList.groupBy { it.pk } val followingMap = followingList.groupBy { it.pk }
val mutual: MutableList<User> = mutableListOf() val mutual: MutableList<User> = mutableListOf()
val onlyFollowing: MutableList<User> = mutableListOf()
val onlyFollowers: MutableList<User> = mutableListOf() val onlyFollowers: MutableList<User> = mutableListOf()
allUsers.forEach { followersList.forEach {
val isFollowing = followingMap.get(it.pk) != null if (followingMap.get(it.pk) != null) mutual.add(it)
val isFollower = followersMap.get(it.pk) != null else onlyFollowers.add(it)
if (isFollowing && isFollower) mutual.add(it)
else if (isFollowing) onlyFollowing.add(it)
else if (isFollower) onlyFollowers.add(it)
} }
val mutualMap = mutual.groupBy { it.pk }
val onlyFollowing = followingList.filter { mutualMap.get(it.pk) == null }
postValue(Triple(mutual, onlyFollowing, onlyFollowers)) postValue(Triple(mutual, onlyFollowing, onlyFollowers))
} }
} }