Skip to content
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 @@ -243,7 +243,8 @@ class ReaderPostMoreButtonUiStateBuilder @Inject constructor(
menuItems: MutableList<ReaderPostCardAction>,
onButtonClicked: (Long, Long, ReaderPostCardActionType) -> Unit
) {
if (!readerUtilsWrapper.isSelfHosted(post.authorBlogId)) {
val hasWordPressAccount = post.authorId > 0
if (hasWordPressAccount) {
menuItems.add(buildReportUser(onButtonClicked))
menuItems.add(buildBlockUser(onButtonClicked))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,13 +593,4 @@ object ReaderUtils {
fun commentExists(blogId: Long, postId: Long, commentId: Long): Boolean {
return ReaderCommentTable.commentExists(blogId, postId, commentId)
}

/**
* Self-hosted sites have a site id of 0, but we use -1 to indicate a self-hosted site
*
* @param authorBlogId site id of the post's author
*/
fun isSelfHosted(authorBlogId: Long): Boolean {
return authorBlogId < 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class ReaderUtilsWrapper @Inject constructor(
numComments
)

fun isSelfHosted(authorBlogId: Long) = ReaderUtils.isSelfHosted(authorBlogId)

fun getTagFromTagUrl(url: String): String = ReaderUtils.getTagFromTagUrl(url)

fun getShortLikeLabelText(numLikes: Int): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,9 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `contains report user action for wpcom sites`() = test {
fun `contains report user action when author has a WordPress account`() = test {
// Arrange
val post = init()
whenever(readerUtilsWrapper.isSelfHosted(post.authorId)).thenReturn(false)
val post = init(authorId = 123L)

// Act
val menuItems = builder.buildMoreMenuItems(post, false, dummyOnClick)
Expand All @@ -257,10 +256,9 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `does not contain report user action for self-hosted sites`() = test {
fun `does not contain report user action when author has no WordPress account`() = test {
// Arrange
val post = init()
whenever(readerUtilsWrapper.isSelfHosted(post.authorId)).thenReturn(true)
val post = init(authorId = 0L)

// Act
val menuItems = builder.buildMoreMenuItems(post, false, dummyOnClick)
Expand Down Expand Up @@ -371,10 +369,9 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `does contain block user action for wpcom sites`() = test {
fun `contains block user action when author has a WordPress account`() = test {
// Arrange
val post = init()
whenever(readerUtilsWrapper.isSelfHosted(post.authorId)).thenReturn(false)
val post = init(authorId = 123L)

// Act
val menuItems = builder.buildMoreMenuItems(post, false, dummyOnClick)
Expand All @@ -385,10 +382,9 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
}

@Test
fun `does not contain block user action for self-hosted sites`() = test {
fun `does not contain block user action when author has no WordPress account`() = test {
// Arrange
val post = init()
whenever(readerUtilsWrapper.isSelfHosted(post.authorId)).thenReturn(true)
val post = init(authorId = 0L)

// Act
val menuItems = builder.buildMoreMenuItems(post, false, dummyOnClick)
Expand All @@ -404,7 +400,8 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
isFeed: Boolean = false,
isSeenSupported: Boolean = true,
isSeen: Boolean = false,
isBookmarked: Boolean = false
isBookmarked: Boolean = false,
authorId: Long = 100L
): ReaderPost {
whenever(readerPostTableWrapper.isPostFollowed(anyOrNull())).thenReturn(isFollowed)
whenever(readerPostTableWrapper.isPostSeen(anyOrNull())).thenReturn(isSeen)
Expand All @@ -415,6 +412,7 @@ class ReaderPostMoreButtonUiStateBuilderTest : BaseUnitTest() {
this.isSeenSupported = isSeenSupported
this.isSeen = isSeen
this.isBookmarked = isBookmarked
this.authorId = authorId
}
}
}