Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #13863 - Story Privacy Setting UI issues #13892

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.thoughtcrime.securesms.stories.settings.select

import android.os.Bundle
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.widget.EditText
import androidx.appcompat.widget.Toolbar
import androidx.core.widget.doAfterTextChanged
Expand Down Expand Up @@ -77,6 +79,11 @@ abstract class BaseStoryRecipientSelectionFragment : Fragment(R.layout.stories_b
}

viewModel.state.observe(viewLifecycleOwner) {
actionButton.visibility = if(it.selection.isEmpty()) {
GONE
} else {
VISIBLE
}
if (it.distributionListId == null || it.privateStory != null) {
if (it.isStartingSelection) {
getAttachedContactSelectionFragment().markSelected(it.selection.toSet())
Expand Down Expand Up @@ -141,7 +148,9 @@ abstract class BaseStoryRecipientSelectionFragment : Fragment(R.layout.stories_b
return HeaderAction(
R.string.BaseStoryRecipientSelectionFragment__select_all
) {
viewModel.toggleSelectAll()
viewModel.toggleSelectAll {
getAttachedContactSelectionFragment().markSelected(it)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ class BaseStoryRecipientSelectionViewModel(
disposable.clear()
}

fun toggleSelectAll() {
fun toggleSelectAll(onUpdate: (Set<RecipientId>) -> Unit) {
disposable += repository.getAllSignalContacts().subscribeBy { allSignalRecipients ->
store.update { it.copy(selection = allSignalRecipients) }
onUpdate(allSignalRecipients)
}
}

Expand Down