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
|
package org.thoughtcrime.securesms.stories.viewer
|
||||||
|
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
|
||||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||||
import org.thoughtcrime.securesms.database.model.DistributionListId
|
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.Recipient
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
|
|
||||||
|
@ -13,32 +11,25 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
*/
|
*/
|
||||||
open class StoryViewerRepository {
|
open class StoryViewerRepository {
|
||||||
fun getStories(): Single<List<RecipientId>> {
|
fun getStories(): Single<List<RecipientId>> {
|
||||||
return Single.fromCallable {
|
return Single.create { emitter ->
|
||||||
val storyResults: List<StoryResult> = SignalDatabase.mms.orderedStoryRecipientsAndIds.distinctBy { it.recipientId }
|
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||||
val resolved = storyResults.map { Recipient.resolved(it.recipientId) }
|
val myStories = Recipient.resolved(myStoriesId)
|
||||||
|
val recipientIds = SignalDatabase.mms.orderedStoryRecipientsAndIds.groupBy {
|
||||||
val doNotCollapse: List<RecipientId> = resolved
|
val recipient = Recipient.resolved(it.recipientId)
|
||||||
.filterNot { it.isDistributionList || it.shouldHideStory() }
|
if (recipient.isDistributionList) {
|
||||||
.map { it.id }
|
myStories
|
||||||
|
|
||||||
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++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
count
|
|
||||||
}
|
|
||||||
|
|
||||||
if (myStoriesCount > 0) {
|
|
||||||
listOf(myStory) + doNotCollapse
|
|
||||||
} else {
|
} else {
|
||||||
doNotCollapse
|
recipient
|
||||||
|
}
|
||||||
|
}.keys.filterNot { it.shouldHideStory() }.map { it.id }
|
||||||
|
|
||||||
|
emitter.onSuccess(
|
||||||
|
if (recipientIds.contains(myStoriesId)) {
|
||||||
|
listOf(myStoriesId) + (recipientIds - myStoriesId)
|
||||||
|
} else {
|
||||||
|
recipientIds
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}.subscribeOn(Schedulers.io())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue