Merge pull request #3307 from element-hq/feature/bma/cleanup

Cleanup and add unit test for DefaultPinnedMessagesBannerFormatter
This commit is contained in:
Benoit Marty 2024-08-20 09:10:31 +02:00 committed by GitHub
commit 6b528596ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 825 additions and 29 deletions

View file

@ -29,7 +29,7 @@ data class UserEventPermissions(
) {
companion object {
val DEFAULT = UserEventPermissions(
canRedactOwn = false,
canRedactOwn = true,
canRedactOther = false,
canSendMessage = true,
canSendReaction = true,

View file

@ -71,16 +71,15 @@ fun PinnedMessagesBannerView(
onViewAllClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier) {
when (state) {
PinnedMessagesBannerState.Hidden -> Unit
is PinnedMessagesBannerState.Visible -> {
PinnedMessagesBannerRow(
state = state,
onClick = onClick,
onViewAllClick = onViewAllClick,
)
}
when (state) {
PinnedMessagesBannerState.Hidden -> Unit
is PinnedMessagesBannerState.Visible -> {
PinnedMessagesBannerRow(
state = state,
onClick = onClick,
onViewAllClick = onViewAllClick,
modifier = modifier,
)
}
}
}
@ -136,18 +135,17 @@ private fun ViewAllButton(
onViewAllClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier) {
val text = if (state is PinnedMessagesBannerState.Loaded) {
stringResource(id = CommonStrings.screen_room_pinned_banner_view_all_button_title)
} else {
""
}
TextButton(
text = text,
showProgress = state is PinnedMessagesBannerState.Loading,
onClick = onViewAllClick
)
val text = if (state is PinnedMessagesBannerState.Loaded) {
stringResource(id = CommonStrings.screen_room_pinned_banner_view_all_button_title)
} else {
""
}
TextButton(
text = text,
showProgress = state is PinnedMessagesBannerState.Loading,
onClick = onViewAllClick,
modifier = modifier,
)
}
private fun Modifier.drawBorder(borderColor: Color): Modifier {

View file

@ -431,10 +431,9 @@ class MessageComposerPresenterTest {
}
val fakeMatrixRoom = FakeMatrixRoom(
liveTimeline = timeline,
typingNoticeResult = { Result.success(Unit) }
).apply {
this.editMessageLambda = roomEditMessageLambda
}
typingNoticeResult = { Result.success(Unit) },
editMessageLambda = roomEditMessageLambda,
)
val presenter = createPresenter(
this,
fakeMatrixRoom,