Fixed conversation subject not pre-filled when scheduling meeting

This commit is contained in:
Sylvain Berfini 2024-11-13 16:55:48 +01:00
parent 3fcbc9bf28
commit a96940b94a
6 changed files with 26 additions and 11 deletions

View file

@ -169,11 +169,13 @@ class ConversationInfoFragment : SlidingPaneChildFragment() {
}
viewModel.goToScheduleMeetingEvent.observe(viewLifecycleOwner) {
it.consume { participants ->
it.consume { pair ->
val subject = pair.first
val participants = pair.second
Log.i(
"$TAG Forward participants list of size [${participants.size}] to schedule meeting fragment"
"$TAG Forward subject [$subject] and participants list of size [${participants.size}] to schedule meeting fragment"
)
sharedViewModel.goToScheduleMeetingEvent.postValue(Event(participants))
sharedViewModel.goToScheduleMeetingEvent.postValue(Event(pair))
sharedViewModel.navigateToMeetingsEvent.postValue(Event(true))
}
}

View file

@ -92,8 +92,8 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
MutableLiveData<Event<Pair<View, ParticipantModel>>>()
}
val goToScheduleMeetingEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
MutableLiveData<Event<ArrayList<String>>>()
val goToScheduleMeetingEvent: MutableLiveData<Event<Pair<String, ArrayList<String>>>> by lazy {
MutableLiveData<Event<Pair<String, ArrayList<String>>>>()
}
private val chatRoomListener = object : ChatRoomListenerStub() {
@ -269,14 +269,16 @@ class ConversationInfoViewModel @UiThread constructor() : AbstractConversationVi
val participantsList = arrayListOf<String>()
for (participant in chatRoom.participants) {
participantsList.add(participant.address.asStringUriOnly())
goToScheduleMeetingEvent.postValue(Event(participantsList))
}
goToScheduleMeetingEvent.postValue(
Event(Pair(chatRoom.subject.orEmpty(), participantsList))
)
} else {
val firstParticipant = chatRoom.participants.firstOrNull()
val address = firstParticipant?.address
if (address != null) {
val participantsList = arrayListOf(address.asStringUriOnly())
goToScheduleMeetingEvent.postValue(Event(participantsList))
goToScheduleMeetingEvent.postValue(Event(Pair("", participantsList)))
} else {
Log.e("$TAG Failed to find participant to call!")
}

View file

@ -229,14 +229,17 @@ class MeetingsListFragment : AbstractMainFragment() {
}
sharedViewModel.goToScheduleMeetingEvent.observe(viewLifecycleOwner) {
it.consume { participants ->
it.consume { pair ->
if (findNavController().currentDestination?.id == R.id.meetingsListFragment) {
val subject = pair.first
val participants = pair.second
val participantsArray = participants.toTypedArray()
Log.i(
"$TAG Going to schedule meeting fragment with pre-populated participants array of size [${participantsArray.size}]"
"$TAG Going to schedule meeting fragment with pre-populated subject [$subject] and participants array of size [${participantsArray.size}]"
)
val action =
MeetingsListFragmentDirections.actionMeetingsListFragmentToScheduleMeetingFragment(
subject,
participantsArray
)
findNavController().navigate(action)

View file

@ -88,6 +88,9 @@ class ScheduleMeetingFragment : GenericMainFragment() {
binding.viewModel = viewModel
observeToastEvents(viewModel)
val subject = args.subject
viewModel.subject.value = subject
val participants = args.participants
if (!participants.isNullOrEmpty()) {
Log.i("$TAG Found pre-populated array of participants of size [${participants.size}]")

View file

@ -171,8 +171,8 @@ class SharedMainViewModel @UiThread constructor() : ViewModel() {
MutableLiveData<Event<String>>()
}
val goToScheduleMeetingEvent: MutableLiveData<Event<ArrayList<String>>> by lazy {
MutableLiveData<Event<ArrayList<String>>>()
val goToScheduleMeetingEvent: MutableLiveData<Event<Pair<String, ArrayList<String>>>> by lazy {
MutableLiveData<Event<Pair<String, ArrayList<String>>>>()
}
/* Recordings related */

View file

@ -337,6 +337,11 @@
app:exitAnim="@anim/slide_out_left"
app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right" />
<argument
android:name="subject"
app:argType="string"
app:nullable="false"
android:defaultValue="" />
<argument
android:name="participants"
app:argType="string[]"