When sharing to a room save a draft to pre-fill the composer

This commit is contained in:
Benoit Marty 2020-02-18 12:11:51 +01:00
parent 8d1b2b35fd
commit 7b3fcb7798
2 changed files with 5 additions and 4 deletions

View file

@ -303,13 +303,14 @@ class RoomDetailFragment @Inject constructor(
if (savedInstanceState == null) {
when (val sharedData = roomDetailArgs.sharedData) {
is SharedData.Text -> {
roomDetailViewModel.handle(RoomDetailAction.ExitSpecialMode(composerLayout.text.toString()))
// Save a draft to set the shared text to the composer
roomDetailViewModel.handle(RoomDetailAction.SaveDraft(sharedData.text))
}
is SharedData.Attachments -> {
// open share edition
onContentAttachmentsReady(sharedData.attachmentData)
}
null -> Timber.v("No share data to process")
null -> Timber.v("No share data to process")
}.exhaustive
}
}
@ -435,7 +436,7 @@ class RoomDetailFragment @Inject constructor(
composerLayout.collapse()
updateComposerText(text)
composerLayout.sendButton.setContentDescription(getString(R.string.send))
composerLayout.sendButton.contentDescription = getString(R.string.send)
}
private fun renderSpecialMode(event: TimelineEvent,

View file

@ -243,7 +243,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
is SendMode.REPLY -> room.saveDraft(UserDraft.REPLY(it.sendMode.timelineEvent.root.eventId!!, action.draft), NoOpMatrixCallback())
is SendMode.QUOTE -> room.saveDraft(UserDraft.QUOTE(it.sendMode.timelineEvent.root.eventId!!, action.draft), NoOpMatrixCallback())
is SendMode.EDIT -> room.saveDraft(UserDraft.EDIT(it.sendMode.timelineEvent.root.eventId!!, action.draft), NoOpMatrixCallback())
}
}.exhaustive
}
}