Ensure sent group stories are included in the My Stories item.
This commit is contained in:
parent
b32fe003b2
commit
14f9a3c155
3 changed files with 20 additions and 11 deletions
|
@ -829,7 +829,8 @@ public class MmsDatabase extends MessageDatabase {
|
|||
while (cursor.moveToNext()) {
|
||||
results.add(new StoryResult(RecipientId.from(CursorUtil.requireLong(cursor, ThreadDatabase.RECIPIENT_ID)),
|
||||
CursorUtil.requireLong(cursor, "mms_id"),
|
||||
CursorUtil.requireLong(cursor, "sent_timestamp")));
|
||||
CursorUtil.requireLong(cursor, "sent_timestamp"),
|
||||
CursorUtil.requireBoolean(cursor, "is_outgoing")));
|
||||
}
|
||||
|
||||
return results;
|
||||
|
|
|
@ -5,5 +5,6 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
|||
class StoryResult(
|
||||
val recipientId: RecipientId,
|
||||
val messageId: Long,
|
||||
val messageSentTimestamp: Long
|
||||
val messageSentTimestamp: Long,
|
||||
val isOutgoing: Boolean
|
||||
)
|
||||
|
|
|
@ -34,16 +34,23 @@ class StoriesLandingRepository(context: Context) {
|
|||
val myStoriesId = SignalDatabase.recipients.getOrInsertFromDistributionListId(DistributionListId.MY_STORY)
|
||||
val myStories = Recipient.resolved(myStoriesId)
|
||||
|
||||
emitter.onNext(
|
||||
SignalDatabase.mms.orderedStoryRecipientsAndIds.groupBy {
|
||||
val recipient = Recipient.resolved(it.recipientId)
|
||||
if (recipient.isDistributionList) {
|
||||
myStories
|
||||
} else {
|
||||
recipient
|
||||
}
|
||||
val stories = SignalDatabase.mms.orderedStoryRecipientsAndIds
|
||||
val mapping: MutableMap<Recipient, List<StoryResult>> = mutableMapOf()
|
||||
|
||||
stories.forEach {
|
||||
val recipient = Recipient.resolved(it.recipientId)
|
||||
if (recipient.isDistributionList || it.isOutgoing) {
|
||||
val list = mapping[myStories] ?: emptyList()
|
||||
mapping[myStories] = list + it
|
||||
}
|
||||
)
|
||||
|
||||
if (!recipient.isDistributionList) {
|
||||
val list = mapping[recipient] ?: emptyList()
|
||||
mapping[recipient] = list + it
|
||||
}
|
||||
}
|
||||
|
||||
emitter.onNext(mapping)
|
||||
}
|
||||
|
||||
val observer = DatabaseObserver.Observer {
|
||||
|
|
Loading…
Add table
Reference in a new issue