fix: combine profile query
This commit is contained in:
parent
d4ab0ad57d
commit
a9b4916dd8
3 changed files with 17 additions and 9 deletions
|
@ -1293,7 +1293,7 @@ Page(page:$page,perPage:50) {
|
|||
|
||||
suspend fun getUserProfile(id: Int): Query.UserProfileResponse? {
|
||||
return executeQuery<Query.UserProfileResponse>(
|
||||
"""{user:User(id:$id){id,name,about(asHtml:true)avatar{medium,large},bannerImage,isFollowing,isFollower,isBlocked,favourites{anime{nodes{id,coverImage{extraLarge,large,medium,color}}}manga{nodes{id,coverImage{extraLarge,large,medium,color}}}characters{nodes{id,name{first,middle,last,full,native,alternative,userPreferred},image{large,medium}}}staff{nodes{id,name{first,middle,last,full,native,alternative,userPreferred},image{large,medium}}}studios{nodes{id,name}}}statistics{anime{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}manga{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}}siteUrl}}""",
|
||||
"""{followerPage:Page{followers(userId:$id){id}pageInfo{total}}followingPage:Page{following(userId:$id){id}pageInfo{total}}user:User(id:$id){id,name,about(asHtml:true)avatar{medium,large},bannerImage,isFollowing,isFollower,isBlocked,favourites{anime{nodes{id,coverImage{extraLarge,large,medium,color}}}manga{nodes{id,coverImage{extraLarge,large,medium,color}}}characters{nodes{id,name{first,middle,last,full,native,alternative,userPreferred},image{large,medium}}}staff{nodes{id,name{first,middle,last,full,native,alternative,userPreferred},image{large,medium}}}studios{nodes{id,name}}}statistics{anime{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}manga{count,meanScore,standardDeviation,minutesWatched,episodesWatched,chaptersRead,volumesRead}}siteUrl}}""",
|
||||
force = true
|
||||
)
|
||||
}
|
||||
|
|
|
@ -208,10 +208,21 @@ class Query {
|
|||
) : java.io.Serializable {
|
||||
@Serializable
|
||||
data class Data(
|
||||
@SerialName("followerPage")
|
||||
val followerPage: UserProfilePage?,
|
||||
@SerialName("followingPage")
|
||||
val followingPage: UserProfilePage?,
|
||||
@SerialName("user")
|
||||
val user: UserProfile?
|
||||
) : java.io.Serializable
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class UserProfilePage(
|
||||
@SerialName("pageInfo")
|
||||
val pageInfo: PageInfo,
|
||||
) : java.io.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Following(
|
||||
@SerialName("data")
|
||||
|
|
|
@ -75,8 +75,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
finish()
|
||||
return@launch
|
||||
}
|
||||
val following = Anilist.query.userFollowers(userid)?.data?.page?.followers
|
||||
val followers = Anilist.query.userFollowing(userid)?.data?.page?.following
|
||||
val following = respond.data.followingPage?.pageInfo?.total?:0
|
||||
val followers = respond.data.followerPage?.pageInfo?.total?:0
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = navBarHeight
|
||||
|
@ -185,9 +185,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
mMaxScrollSize = binding.profileAppBar.totalScrollRange
|
||||
binding.profileAppBar.addOnOffsetChangedListener(this@ProfileActivity)
|
||||
|
||||
followers?.count()?.let {
|
||||
binding.profileFollowerCount.text = it.toString()
|
||||
}
|
||||
|
||||
binding.profileFollowerCount.text = followers.toString()
|
||||
binding.profileFollowerCountContainer.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
this@ProfileActivity,
|
||||
|
@ -198,9 +197,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
|||
)
|
||||
}
|
||||
|
||||
following?.count()?.let {
|
||||
binding.profileFollowingCount.text = it.toString()
|
||||
}
|
||||
binding.profileFollowingCount.text = following.toString()
|
||||
binding.profileFollowingCountContainer.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
this@ProfileActivity,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue