kopia lustrzana https://github.com/ryukoposting/Signal-Android
Adjust viewer ordering to match landing page.
rodzic
1746f37276
commit
a75d2cfa34
|
@ -1,10 +1,8 @@
|
|||
package org.thoughtcrime.securesms.stories.viewer
|
||||
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.DistributionListId
|
||||
import org.thoughtcrime.securesms.database.model.StoryResult
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
|
||||
|
@ -13,32 +11,25 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||
*/
|
||||
open class StoryViewerRepository {
|
||||
fun getStories(): Single<List<RecipientId>> {
|
||||
return Single.fromCallable {
|
||||
val storyResults: List<StoryResult> = SignalDatabase.mms.orderedStoryRecipientsAndIds.distinctBy { it.recipientId }
|
||||
val resolved = storyResults.map { Recipient.resolved(it.recipientId) }
|
||||
|
||||
val doNotCollapse: List<RecipientId> = resolved
|
||||
.filterNot { it.isDistributionList || it.shouldHideStory() }
|
||||
.map { it.id }
|
||||
|
||||
val myStory: RecipientId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||
|
||||
val myStoriesCount = SignalDatabase.mms.getAllOutgoingStories(true).use {
|
||||
var count = 0
|
||||
while (it.next != null) {
|
||||
if (!it.current.recipient.isGroup) {
|
||||
count++
|
||||
}
|
||||
return Single.create { emitter ->
|
||||
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||
val myStories = Recipient.resolved(myStoriesId)
|
||||
val recipientIds = SignalDatabase.mms.orderedStoryRecipientsAndIds.groupBy {
|
||||
val recipient = Recipient.resolved(it.recipientId)
|
||||
if (recipient.isDistributionList) {
|
||||
myStories
|
||||
} else {
|
||||
recipient
|
||||
}
|
||||
}.keys.filterNot { it.shouldHideStory() }.map { it.id }
|
||||
|
||||
count
|
||||
}
|
||||
|
||||
if (myStoriesCount > 0) {
|
||||
listOf(myStory) + doNotCollapse
|
||||
} else {
|
||||
doNotCollapse
|
||||
}
|
||||
}.subscribeOn(Schedulers.io())
|
||||
emitter.onSuccess(
|
||||
if (recipientIds.contains(myStoriesId)) {
|
||||
listOf(myStoriesId) + (recipientIds - myStoriesId)
|
||||
} else {
|
||||
recipientIds
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue