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

Don't color posts as read in post activity #1076

Merged
Merged
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 @@ -430,6 +430,7 @@ fun PostActivity(
openImageViewer = appState::toView,
openLink = appState::openLink,
showPostLinkPreview = showPostLinkPreview,
showIfRead = false,
)
}

Expand Down
17 changes: 15 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/post/PostListing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ fun PostTitleBlock(
blurNSFW: Boolean,
openLink: (String, Boolean, Boolean) -> Unit,
openImageViewer: (url: String) -> Unit,
showIfRead: Boolean = true,
) {
val imagePost = postView.post.url?.let { getPostType(it) == PostType.Image } ?: false

Expand All @@ -284,6 +285,7 @@ fun PostTitleBlock(
postView = postView,
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
showIfRead = showIfRead,
)
} else {
PostTitleAndThumbnail(
Expand All @@ -294,13 +296,15 @@ fun PostTitleBlock(
blurNSFW = blurNSFW,
openLink = openLink,
openImageViewer = openImageViewer,
showIfRead = showIfRead,
)
}
}

@Composable
fun PostName(
postView: PostView,
showIfRead: Boolean = true,
) {
var color = if (postView.post.featured_local) {
MaterialTheme.colorScheme.primary
Expand All @@ -310,7 +314,7 @@ fun PostName(
MaterialTheme.colorScheme.onSurface
}

if (postView.read) {
if (showIfRead && postView.read) {
color = color.muted
}

Expand All @@ -327,6 +331,7 @@ fun PostTitleAndImageLink(
postView: PostView,
blurNSFW: Boolean,
openImageViewer: (url: String) -> Unit,
showIfRead: Boolean = true,
) {
// This was tested, we know it exists
val url = postView.post.url!!
Expand All @@ -341,6 +346,7 @@ fun PostTitleAndImageLink(
// Title of the post
PostName(
postView = postView,
showIfRead = showIfRead,
)
}

Expand All @@ -362,6 +368,7 @@ fun PostTitleAndThumbnail(
blurNSFW: Boolean,
openLink: (String, Boolean, Boolean) -> Unit,
openImageViewer: (url: String) -> Unit,
showIfRead: Boolean = true,
) {
Column(
modifier = Modifier.padding(horizontal = MEDIUM_PADDING),
Expand All @@ -374,7 +381,7 @@ fun PostTitleAndThumbnail(
verticalArrangement = Arrangement.spacedBy(MEDIUM_PADDING),
modifier = Modifier.weight(1f),
) {
PostName(postView = postView)
PostName(postView = postView, showIfRead = showIfRead)
postView.post.url?.also { postUrl ->
if (!isSameInstance(postUrl, account?.instance)) {
val hostName = hostName(postUrl)
Expand Down Expand Up @@ -414,6 +421,7 @@ fun PostBody(
openImageViewer: (url: String) -> Unit,
openLink: (String, Boolean, Boolean) -> Unit,
clickBody: () -> Unit = {},
showIfRead: Boolean = true,
) {
val post = postView.post
Column(
Expand All @@ -428,6 +436,7 @@ fun PostBody(
blurNSFW = blurNSFW,
openImageViewer = openImageViewer,
openLink = openLink,
showIfRead = showIfRead,
)

// The metadata card
Expand Down Expand Up @@ -946,6 +955,7 @@ fun PostListing(
openLink: (String, Boolean, Boolean) -> Unit,
openImageViewer: (url: String) -> Unit,
showPostLinkPreview: Boolean,
showIfRead: Boolean = true,
) {
// This stores vote data
val instantScores = remember {
Expand Down Expand Up @@ -1008,6 +1018,7 @@ fun PostListing(
openLink = openLink,
openImageViewer = openImageViewer,
showPostLinkPreview = showPostLinkPreview,
showIfRead = showIfRead,
)

PostViewMode.SmallCard -> PostListingCard(
Expand Down Expand Up @@ -1422,6 +1433,7 @@ fun PostListingCard(
showPostLinkPreview: Boolean,
openLink: (String, Boolean, Boolean) -> Unit,
openImageViewer: (url: String) -> Unit,
showIfRead: Boolean = false,
) {
Column(
modifier = Modifier
Expand Down Expand Up @@ -1458,6 +1470,7 @@ fun PostListingCard(
openImageViewer = openImageViewer,
clickBody = { onPostClick(postView) },
openLink = openLink,
showIfRead = showIfRead,
)

// Footer bar
Expand Down