Skip to content

Commit

Permalink
Don't color posts as read in post activity (#1076)
Browse files Browse the repository at this point in the history
Co-authored-by: Maarten Vercruysse <[email protected]>
  • Loading branch information
twizmwazin and MV-GH authored Jul 21, 2023
1 parent fdf0ddd commit c9786f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit c9786f0

Please sign in to comment.