Skip to content

Commit

Permalink
Ignore zero children posts and jump to the single children if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
HeroBrine1st committed Nov 12, 2023
1 parent 1a2740c commit 565e9c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,24 @@ class PostComponent(
}

fun openChildrenPostListing() {
val post = post!!
post.relationships.children.singleOrNull()?.let { id ->
navigator.pushIndexed { it ->
Config.Post(
id = id,
post = null,
query = PostsSearchOptions(),
index = it
)
}
return
}
navigator.pushIndexed { index ->
Config.PostListing(
search = PostsSearchOptions(
// TODO get safe mode synchronously
// (post listing has filter for safe mode)
parent = post!!.id
parent = post.id
),
index = index
)
Expand Down Expand Up @@ -319,4 +331,4 @@ class PostComponent(
}

@Parcelize
object PoolsDialogConfig: Parcelable
object PoolsDialogConfig : Parcelable
4 changes: 2 additions & 2 deletions app/src/main/java/ru/herobrine1st/e621/ui/screen/post/Post.kt
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ fun Post(
Spacer(Modifier.weight(1f))
}
)
if (post.relationships.hasChildren) TextButton(
if (post.relationships.hasChildren && post.relationships.children.isNotEmpty()) TextButton(
onClick = component::openChildrenPostListing,
content = {
Text(stringResource(R.string.children_posts))
Text(stringResource(R.string.children_posts, post.relationships.children.size))
Spacer(Modifier.weight(1f))
}
)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-ru-rRU/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<string name="parent_post">Родительский пост</string>
<string name="post_id">Идентификатор поста</string>
<string name="safe_mode_blocks_post">Пост не может быть показан: его рейтинг не совместим с безопасным режимом.</string>
<string name="children_posts">Дочерние посты</string>
<string name="children_posts">Дочерние посты (%d)</string>
<string name="post_has_pool">Коллекция этого поста</string>
<string name="post_has_pools">Коллекции этого поста (%d)</string>
<string name="pools_dialog_select_pool">Выберите коллекцию для просмотра</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ You should have received a copy of the GNU General Public License along with thi
<string name="parent_post">Parent post</string>
<string name="post_id">Post id</string>
<string name="safe_mode_blocks_post">Can\'t show this post: its rating is incompatible with safe mode.</string>
<string name="children_posts">Children posts</string>
<string name="children_posts">Children posts (%d)</string>
<string name="post_has_pool">View attached pool</string>
<string name="post_has_pools">View attached pools (%d)</string>
<string name="pools_dialog_select_pool">Select pool to view</string>
Expand Down

0 comments on commit 565e9c3

Please sign in to comment.