mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 07:48:44 +01:00
fix(api): improve Lemmy 0.19 compatibility (#173)
* fix: optional fields * fix: back to top when changing instance in anon mode
This commit is contained in:
parent
5cdaf36faf
commit
d1f1ad51d9
@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CommentAggregates(
|
||||
@SerialName("id") val id: Int,
|
||||
@SerialName("id") val id: Int? = null,
|
||||
@SerialName("comment_id") val commentId: CommentId,
|
||||
@SerialName("score") val score: Int,
|
||||
@SerialName("upvotes") val upvotes: Int,
|
||||
|
@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CommunityAggregates(
|
||||
@SerialName("id") val id: Int,
|
||||
@SerialName("id") val id: Int? = null,
|
||||
@SerialName("community_id") val communityId: CommunityId,
|
||||
@SerialName("subscribers") val subscribers: Int,
|
||||
@SerialName("posts") val posts: Int,
|
||||
|
@ -5,10 +5,10 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PersonAggregates(
|
||||
@SerialName("id") val id: Int,
|
||||
@SerialName("id") val id: Int? = null,
|
||||
@SerialName("person_id") val personId: PersonId,
|
||||
@SerialName("post_count") val postCount: Int,
|
||||
@SerialName("post_score") val postScore: Int,
|
||||
@SerialName("post_score") val postScore: Int? = null,
|
||||
@SerialName("comment_count") val commentCount: Int,
|
||||
@SerialName("comment_score") val commentScore: Int,
|
||||
@SerialName("comment_score") val commentScore: Int? = null,
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PostAggregates(
|
||||
@SerialName("id") val id: Int,
|
||||
@SerialName("id") val id: Int? = null,
|
||||
@SerialName("post_id") val postId: PostId,
|
||||
@SerialName("comments") val comments: Int,
|
||||
@SerialName("score") val score: Int,
|
||||
|
@ -5,7 +5,7 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class SiteAggregates(
|
||||
@SerialName("id") val id: Int,
|
||||
@SerialName("id") val id: Int? = null,
|
||||
@SerialName("site_id") val siteOd: SiteId,
|
||||
@SerialName("users") val users: Int,
|
||||
@SerialName("posts") val posts: Int,
|
||||
|
@ -7,6 +7,6 @@ import kotlinx.serialization.Serializable
|
||||
data class SiteView(
|
||||
@SerialName("site") val site: Site,
|
||||
@SerialName("local_site") val localSite: LocalSite,
|
||||
@SerialName("local_site_rate_limit") val localSiteRateLimit: LocalSiteRateLimit,
|
||||
@SerialName("local_site_rate_limit") val localSiteRateLimit: LocalSiteRateLimit?,
|
||||
@SerialName("counts") val counts: SiteAggregates,
|
||||
)
|
||||
|
@ -99,8 +99,8 @@ internal fun Person.toModel() = UserModel(
|
||||
internal fun PersonView.toModel() = person.toModel()
|
||||
|
||||
internal fun PersonAggregates.toModel() = UserScoreModel(
|
||||
postScore = postScore,
|
||||
commentScore = commentScore,
|
||||
postScore = postScore ?: 0,
|
||||
commentScore = commentScore ?: 0,
|
||||
)
|
||||
|
||||
internal fun PostView.toModel() = PostModel(
|
||||
|
@ -60,8 +60,9 @@ class PostListViewModel(
|
||||
it.copy(instance = instance)
|
||||
}
|
||||
}.launchIn(this)
|
||||
apiConfigRepository.instance.drop(1).onEach { instance ->
|
||||
apiConfigRepository.instance.drop(1).onEach { _ ->
|
||||
refresh()
|
||||
mvi.emitEffect(PostListMviModel.Effect.BackToTop)
|
||||
}.launchIn(this)
|
||||
|
||||
identityRepository.authToken.map { !it.isNullOrEmpty() }.onEach { isLogged ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user