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

Comment fields in ConversationEntity related to expanding and collapsing content #3886

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.keylesspalace.tusky.entity.TimelineAccount
import com.keylesspalace.tusky.viewdata.StatusViewData
import java.util.Date

/** A reply-tree of statuses which have been saved to disk. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a tree. The API for conversations returns the most recent (last) status in the thread. You can see this in Tusky if you open the DMs tab; each DM (conversation) is represented by the last status in the message thread. You have to tap on that message to see the full thread.

"saved to disk" is an implementation detail.

For commenting these I've found it helpful to link directly to the relevant Mastodon API documentation. For this one, it's a https://docs.joinmastodon.org/entities/Conversation/

@Entity(primaryKeys = ["id", "accountId"])
@TypeConverters(Converters::class)
data class ConversationEntity(
Expand All @@ -50,6 +51,7 @@ data class ConversationEntity(
}
}

/** The account information associated with a status saved to disk. */
data class ConversationAccountEntity(
val id: String,
val localUsername: String,
Expand All @@ -72,6 +74,7 @@ data class ConversationAccountEntity(
}
}

/** A previously-displayed status which has been saved to disk. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@connyduck In the Mastodon API the Converstation entity contains a regular Status entity.

Why is it a different type here? And can that reasoning please be added to the comment.

@TypeConverters(Converters::class)
data class ConversationStatusEntity(
val id: String,
Expand All @@ -87,14 +90,20 @@ data class ConversationStatusEntity(
val repliesCount: Int,
val favourited: Boolean,
val bookmarked: Boolean,
/** If true, post attachments are marked as sensitive content. */
val sensitive: Boolean,
/** If nonempty, post text has a spoiler/content warning. */
val spoilerText: String,
val attachments: List<Attachment>,
val mentions: List<Status.Mention>,
val tags: List<HashTag>?,
/** If sensitive is true, then this is true when the user has chosen to expose the attachments. */
val showingHiddenContent: Boolean,
/** If spoilerText is nonempty, then this is true when the user has chosen to show the text. */
val expanded: Boolean,
/** If content is long (see shouldTrimStatus()), then this is *false* when the user has chosen to show all content. */
val collapsed: Boolean,
/** If true, the user has chosen not to see further notifications for this status. */
val muted: Boolean,
val poll: Poll?,
val language: String?
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/com/keylesspalace/tusky/entity/Status.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.google.gson.annotations.SerializedName
import com.keylesspalace.tusky.util.parseAsMastodonHtml
import java.util.Date

/** A Mastodon status as the server sees it. (Distinct from ConversationStatusEntity or StatusViewData.Concrete). */
data class Status(
val id: String,
val url: String?, // not present if it's reblog
Expand All @@ -38,24 +39,29 @@ data class Status(
val reblogged: Boolean,
val favourited: Boolean,
val bookmarked: Boolean,
/** If true, post attachments are marked as sensitive content. */
val sensitive: Boolean,
/** If nonempty, post text has a spoiler/content warning. */
@SerializedName("spoiler_text") val spoilerText: String,
val visibility: Visibility,
@SerializedName("media_attachments") val attachments: List<Attachment>,
val mentions: List<Mention>,
val tags: List<HashTag>?,
val application: Application?,
val pinned: Boolean?,
/** If true, the user has chosen not to see further notifications for this status. */
val muted: Boolean?,
val poll: Poll?,
val card: Card?,
val language: String?,
/** If true, the server reports a user-custom content filter applies to the status. */
val filtered: List<FilterResult>?
) {

val actionableId: String
get() = reblog?.id ?: id

/** If status is a reblog, the "true" status, otherwise self. */
val actionableStatus: Status
get() = reblog ?: this

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,63 @@ import com.keylesspalace.tusky.util.shouldTrimStatus
/**
* Created by charlag on 11/07/2017.
*
* Class to represent data required to display either a notification or a placeholder.
* Class to represent data required to display either a status or a placeholder ("Load More" bar).
* It is either a [StatusViewData.Concrete] or a [StatusViewData.Placeholder].
* Can be created either from a ConversationStatusEntity, or by helpers in ViewDataUtils.
Comment on lines -28 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be OK with holding off on adding the comments here, and adding them as suggestions to https://github.com/tuskyapp/Tusky/pull/3436/files#diff-eb35dc96f92845f7f47b51230940e1c57928b5337d164e64567f3511b19b9647 instead? It'll make syncing that PR with head easier, and that PR removes the .Placeholder type, so there's probably no point documenting it here.

That PR also includes some of the same comments that you're making here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my question is, is PR #3436 on track for v24 inclusion? If so, then I agree it would make more sense to glom onto 3436. If not, I think it would be better to do a comments-only patch now. I could do the patch-3436 merge conflict resolution myself if that would help.

Copy link
Contributor

@nikclayton nikclayton Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my question is, is PR #3436 on track for v24 inclusion?

¯\(ツ)

Needs a code review and more people to try the APK.

*/
sealed class StatusViewData {
abstract val id: String
var filterAction: Filter.Action = Filter.Action.NONE

data class Concrete(
/** The Mastodon-API level information about the status. */
val status: Status,
/**
* If StatusViewData spoilerText is nonempty, specifies whether the text content of this post
* is currently hidden.
*
* @return If true, post is shown. If false, it is hidden.
*/
val isExpanded: Boolean,
/**
* Specifies whether attachments are currently hidden as sensitive.
*
* @return If true, attachments are shown. If false, they is hidden.
*/
val isShowingContent: Boolean,
/**
* Specifies whether the content of this post is currently limited in visibility to the first
* 500 characters or not.
* If StatusViewData isCollapsible, specifies whether the content of this post is currently
* limited in visibility to the first characters or not.
*
* @return Whether the post is collapsed or fully expanded.
* @return If true, post is collapsed. If false, it is fully expanded.
*/
val isCollapsed: Boolean,
/**
* If true, the status is "big" (has been selected by the user for detailed display).
*/
val isDetailed: Boolean = false
) : StatusViewData() {
override val id: String
get() = status.id

/**
* Specifies whether the content of this post is long enough to be automatically
* collapsed or if it should show all content regardless.
* collapsed or if it should show all content regardless. (See shouldTrimStatus())
*
* @return Whether the post is collapsible or never collapsed.
*/
val isCollapsible: Boolean

val content: Spanned

/**
* @return If nonempty, the spoiler/content warning text. If empty, there is no warning.
*/
val spoilerText: String
val username: String

/**
* @return The "true" status (same as status unless this is a reblog)
*/
val actionable: Status
get() = status.actionableStatus

Expand Down