mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Support dynamically updating common groups in recipient settings.
This commit is contained in:
@@ -100,19 +100,23 @@ class ConversationSettingsRepository(
|
||||
}
|
||||
}
|
||||
|
||||
fun getGroupsInCommon(recipientId: RecipientId, consumer: (List<Recipient>) -> Unit) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
consumer(
|
||||
SignalDatabase
|
||||
.groups
|
||||
.getPushGroupsContainingMember(recipientId)
|
||||
.asSequence()
|
||||
.filter { it.members.contains(Recipient.self().id) }
|
||||
.map(GroupRecord::recipientId)
|
||||
.map(Recipient::resolved)
|
||||
.sortedBy { gr -> gr.getDisplayName(context) }
|
||||
.toList()
|
||||
)
|
||||
fun getGroupsInCommon(recipientId: RecipientId): Observable<List<Recipient>> {
|
||||
return Recipient.observable(recipientId).flatMapSingle { recipient ->
|
||||
if (recipient.hasGroupsInCommon) {
|
||||
Single.fromCallable {
|
||||
SignalDatabase
|
||||
.groups
|
||||
.getPushGroupsContainingMember(recipientId)
|
||||
.asSequence()
|
||||
.filter { it.members.contains(Recipient.self().id) }
|
||||
.map(GroupRecord::recipientId)
|
||||
.map(Recipient::resolved)
|
||||
.sortedBy { gr -> gr.getDisplayName(context) }
|
||||
.toList()
|
||||
}.observeOn(Schedulers.io())
|
||||
} else {
|
||||
Single.just(listOf())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ sealed class ConversationSettingsViewModel(
|
||||
}
|
||||
|
||||
if (recipientId != Recipient.self().id) {
|
||||
repository.getGroupsInCommon(recipientId) { groupsInCommon ->
|
||||
disposable += repository.getGroupsInCommon(recipientId).subscribe { groupsInCommon ->
|
||||
store.update { state ->
|
||||
val recipientSettings = state.requireRecipientSettingsState()
|
||||
val canShowMore = !recipientSettings.groupsInCommonExpanded && groupsInCommon.size > 6
|
||||
|
||||
Reference in New Issue
Block a user