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

Make datatypes Parcelable and Stable #1044

Merged
merged 6 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ plugins {
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
id("androidx.baselineprofile")
id("kotlin-parcelize")

}

apply(from = "update_instances.gradle.kts")
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/com/jerboa/datatypes/SampleData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ val samplePostAggregates = PostAggregates(
newest_comment_time_necro = "2022-01-02T04:02:44.592929",
newest_comment_time = "2022-01-02T04:02:44.592929",
published = "2022-01-02T04:02:44.592929",
hot_rank = 5,
hot_rank_active = 6,
)

val samplePostView = PostView(
Expand Down Expand Up @@ -346,6 +348,7 @@ val sampleCommentAggregates = CommentAggregates(
downvotes = 4,
published = "2022-01-02T04:02:44.592929",
child_count = 0,
hot_rank = 6,
)

val sampleCommentView = CommentView(
Expand Down Expand Up @@ -444,6 +447,7 @@ val sampleCommunityAggregates = CommunityAggregates(
users_active_week = 98,
users_active_month = 82,
users_active_half_year = 91,
hot_rank = 3,
)

val sampleCommunityView = CommunityView(
Expand Down Expand Up @@ -517,7 +521,6 @@ val sampleLocalSite = LocalSite(
captcha_enabled = false,
default_post_listing_type = ListingType.All,
default_theme = "main",
federation_debug = false,
federation_enabled = true,
federation_worker_count = 64,
id = 1,
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/com/jerboa/datatypes/types/AddAdmin.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AddAdmin(
val person_id: PersonId,
val added: Boolean,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import androidx.compose.runtime.Immutable
import kotlinx.parcelize.Parcelize

@Immutable
@Parcelize
data class AddAdminResponse(
val admins: List<PersonView>,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AddModToCommunity(
val community_id: CommunityId,
val person_id: PersonId,
val added: Boolean,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import androidx.compose.runtime.Immutable
import kotlinx.parcelize.Parcelize

@Immutable
@Parcelize
data class AddModToCommunityResponse(
val moderators: List<CommunityModeratorView>,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgeComment(
val id: Int,
val admin_person_id: PersonId,
val post_id: PostId,
val reason: String? = null,
val when_: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgeCommentView(
val admin_purge_comment: AdminPurgeComment,
val admin: Person? = null,
val post: Post,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgeCommunity(
val id: Int,
val admin_person_id: PersonId,
val reason: String? = null,
val when_: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgeCommunityView(
val admin_purge_community: AdminPurgeCommunity,
val admin: Person? = null,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgePerson(
val id: Int,
val admin_person_id: PersonId,
val reason: String? = null,
val when_: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgePersonView(
val admin_purge_person: AdminPurgePerson,
val admin: Person? = null,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgePost(
val id: Int,
val admin_person_id: PersonId,
val community_id: CommunityId,
val reason: String? = null,
val when_: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class AdminPurgePostView(
val admin_purge_post: AdminPurgePost,
val admin: Person? = null,
val community: Community,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class ApproveRegistrationApplication(
val id: Int,
val approve: Boolean,
val deny_reason: String? = null,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BanFromCommunity(
val community_id: CommunityId,
val person_id: PersonId,
Expand All @@ -8,4 +12,4 @@ data class BanFromCommunity(
val reason: String? = null,
val expires: Int? = null,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BanFromCommunityResponse(
val person_view: PersonView,
val banned: Boolean,
)
) : Parcelable
6 changes: 5 additions & 1 deletion app/src/main/java/com/jerboa/datatypes/types/BanPerson.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BanPerson(
val person_id: PersonId,
val ban: Boolean,
val remove_data: Boolean? = null,
val reason: String? = null,
val expires: Int? = null,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BanPersonResponse(
val person_view: PersonView,
val banned: Boolean,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import androidx.compose.runtime.Immutable
import kotlinx.parcelize.Parcelize

@Immutable
@Parcelize
data class BannedPersonsResponse(
val banned: List<PersonView>,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BlockCommunity(
val community_id: CommunityId,
val block: Boolean,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BlockCommunityResponse(
val community_view: CommunityView,
val blocked: Boolean,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BlockPerson(
val person_id: PersonId,
val block: Boolean,
val auth: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class BlockPersonResponse(
val person_view: PersonView,
val blocked: Boolean,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class CaptchaResponse(
val png: String,
val wav: String,
val uuid: String,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class ChangePassword(
val new_password: String,
val new_password_verify: String,
val old_password: String,
val auth: String,
)
) : Parcelable
6 changes: 5 additions & 1 deletion app/src/main/java/com/jerboa/datatypes/types/Comment.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class Comment(
val id: CommentId,
val creator_id: PersonId,
Expand All @@ -14,4 +18,4 @@ data class Comment(
val path: String,
val distinguished: Boolean,
val language_id: LanguageId,
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jerboa.datatypes.types

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class CommentAggregates(
val id: Int,
val comment_id: CommentId,
Expand All @@ -8,4 +12,5 @@ data class CommentAggregates(
val downvotes: Int,
val published: String,
val child_count: Int,
)
val hot_rank: Int,
) : Parcelable
Loading