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? {
|
suspend fun getUserProfile(id: Int): Query.UserProfileResponse? {
|
||||||
return executeQuery<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
|
force = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,10 +208,21 @@ class Query {
|
||||||
) : java.io.Serializable {
|
) : java.io.Serializable {
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Data(
|
data class Data(
|
||||||
|
@SerialName("followerPage")
|
||||||
|
val followerPage: UserProfilePage?,
|
||||||
|
@SerialName("followingPage")
|
||||||
|
val followingPage: UserProfilePage?,
|
||||||
@SerialName("user")
|
@SerialName("user")
|
||||||
val user: UserProfile?
|
val user: UserProfile?
|
||||||
) : java.io.Serializable
|
) : java.io.Serializable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UserProfilePage(
|
||||||
|
@SerialName("pageInfo")
|
||||||
|
val pageInfo: PageInfo,
|
||||||
|
) : java.io.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class Following(
|
data class Following(
|
||||||
@SerialName("data")
|
@SerialName("data")
|
||||||
|
|
|
@ -75,8 +75,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
finish()
|
finish()
|
||||||
return@launch
|
return@launch
|
||||||
}
|
}
|
||||||
val following = Anilist.query.userFollowers(userid)?.data?.page?.followers
|
val following = respond.data.followingPage?.pageInfo?.total?:0
|
||||||
val followers = Anilist.query.userFollowing(userid)?.data?.page?.following
|
val followers = respond.data.followerPage?.pageInfo?.total?:0
|
||||||
withContext(Dispatchers.Main) {
|
withContext(Dispatchers.Main) {
|
||||||
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
binding.profileViewPager.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
bottomMargin = navBarHeight
|
bottomMargin = navBarHeight
|
||||||
|
@ -185,9 +185,8 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
mMaxScrollSize = binding.profileAppBar.totalScrollRange
|
mMaxScrollSize = binding.profileAppBar.totalScrollRange
|
||||||
binding.profileAppBar.addOnOffsetChangedListener(this@ProfileActivity)
|
binding.profileAppBar.addOnOffsetChangedListener(this@ProfileActivity)
|
||||||
|
|
||||||
followers?.count()?.let {
|
|
||||||
binding.profileFollowerCount.text = it.toString()
|
binding.profileFollowerCount.text = followers.toString()
|
||||||
}
|
|
||||||
binding.profileFollowerCountContainer.setOnClickListener {
|
binding.profileFollowerCountContainer.setOnClickListener {
|
||||||
ContextCompat.startActivity(
|
ContextCompat.startActivity(
|
||||||
this@ProfileActivity,
|
this@ProfileActivity,
|
||||||
|
@ -198,9 +197,7 @@ class ProfileActivity : AppCompatActivity(), AppBarLayout.OnOffsetChangedListene
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
following?.count()?.let {
|
binding.profileFollowingCount.text = following.toString()
|
||||||
binding.profileFollowingCount.text = it.toString()
|
|
||||||
}
|
|
||||||
binding.profileFollowingCountContainer.setOnClickListener {
|
binding.profileFollowingCountContainer.setOnClickListener {
|
||||||
ContextCompat.startActivity(
|
ContextCompat.startActivity(
|
||||||
this@ProfileActivity,
|
this@ProfileActivity,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue