fix (event action): allow to edit only if permission to send message
This commit is contained in:
parent
b2e17622ed
commit
fe3ad46ab9
2 changed files with 46 additions and 1 deletions
|
|
@ -169,7 +169,7 @@ class DefaultActionListPresenter @AssistedInject constructor(
|
||||||
if (timelineItem.isRemote && timelineItem.content.canBeForwarded()) {
|
if (timelineItem.isRemote && timelineItem.content.canBeForwarded()) {
|
||||||
add(TimelineItemAction.Forward)
|
add(TimelineItemAction.Forward)
|
||||||
}
|
}
|
||||||
if (timelineItem.isEditable) {
|
if (timelineItem.isEditable && usersEventPermissions.canSendMessage) {
|
||||||
if (timelineItem.content is TimelineItemEventContentWithAttachment) {
|
if (timelineItem.content is TimelineItemEventContentWithAttachment) {
|
||||||
// Caption
|
// Caption
|
||||||
if (timelineItem.content.caption == null) {
|
if (timelineItem.content.caption == null) {
|
||||||
|
|
|
||||||
|
|
@ -525,6 +525,51 @@ class ActionListPresenterTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `present - compute for my message no permission `() = runTest {
|
||||||
|
val presenter = createActionListPresenter(isDeveloperModeEnabled = true, isPinFeatureEnabled = true)
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
presenter.present()
|
||||||
|
}.test {
|
||||||
|
val initialState = awaitItem()
|
||||||
|
val messageEvent = aMessageEvent(
|
||||||
|
isMine = true,
|
||||||
|
content = TimelineItemTextContent(body = A_MESSAGE, htmlDocument = null, isEdited = false, formattedBody = A_MESSAGE)
|
||||||
|
)
|
||||||
|
initialState.eventSink.invoke(
|
||||||
|
ActionListEvents.ComputeForMessage(
|
||||||
|
event = messageEvent,
|
||||||
|
userEventPermissions = aUserEventPermissions(
|
||||||
|
canRedactOwn = false,
|
||||||
|
canRedactOther = false,
|
||||||
|
canSendMessage = false,
|
||||||
|
canSendReaction = false,
|
||||||
|
canPinUnpin = false,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// val loadingState = awaitItem()
|
||||||
|
// assertThat(loadingState.target).isEqualTo(ActionListState.Target.Loading(messageEvent))
|
||||||
|
val successState = awaitItem()
|
||||||
|
assertThat(successState.target).isEqualTo(
|
||||||
|
ActionListState.Target.Success(
|
||||||
|
event = messageEvent,
|
||||||
|
sentTimeFull = "0 Full true",
|
||||||
|
displayEmojiReactions = false,
|
||||||
|
verifiedUserSendFailure = VerifiedUserSendFailure.None,
|
||||||
|
actions = persistentListOf(
|
||||||
|
TimelineItemAction.Forward,
|
||||||
|
TimelineItemAction.CopyLink,
|
||||||
|
TimelineItemAction.CopyText,
|
||||||
|
TimelineItemAction.ViewSource,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
initialState.eventSink.invoke(ActionListEvents.Clear)
|
||||||
|
assertThat(awaitItem().target).isEqualTo(ActionListState.Target.None)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `present - compute for a media item`() = runTest {
|
fun `present - compute for a media item`() = runTest {
|
||||||
val presenter = createActionListPresenter(isDeveloperModeEnabled = true, isPinFeatureEnabled = true)
|
val presenter = createActionListPresenter(isDeveloperModeEnabled = true, isPinFeatureEnabled = true)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue