Story Privacy Setting UI issues

Fixes #13863
Resolves #13892

Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
Sagar 2025-01-09 00:56:04 +05:30 committed by Cody Henthorne
parent 2174db5bbf
commit 342b11a3ea
2 changed files with 12 additions and 4 deletions

View file

@ -77,6 +77,8 @@ abstract class BaseStoryRecipientSelectionFragment : Fragment(R.layout.stories_b
}
viewModel.state.observe(viewLifecycleOwner) {
actionButton.isEnabled = it.selection.isNotEmpty()
if (it.distributionListId == null || it.privateStory != null) {
if (it.isStartingSelection) {
getAttachedContactSelectionFragment().markSelected(it.selection.toSet())
@ -141,7 +143,9 @@ abstract class BaseStoryRecipientSelectionFragment : Fragment(R.layout.stories_b
return HeaderAction(
R.string.BaseStoryRecipientSelectionFragment__select_all
) {
viewModel.toggleSelectAll()
lifecycleDisposable += viewModel.toggleSelectAll().subscribe { updatedRecipients ->
getAttachedContactSelectionFragment().markSelected(updatedRecipients)
}
}
}

View file

@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import io.reactivex.rxjava3.kotlin.subscribeBy
@ -38,9 +39,12 @@ class BaseStoryRecipientSelectionViewModel(
disposable.clear()
}
fun toggleSelectAll() {
disposable += repository.getAllSignalContacts().subscribeBy { allSignalRecipients ->
store.update { it.copy(selection = allSignalRecipients) }
fun toggleSelectAll(): Single<Set<RecipientId>> {
return Single.create { emitter ->
disposable += repository.getAllSignalContacts().subscribeBy { allSignalRecipients ->
store.update { it.copy(selection = allSignalRecipients) }
emitter.onSuccess(allSignalRecipients)
}
}
}