mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 21:43:19 +02:00
BugFix: Chat List updating immediately when new messages arrive.
This commit is contained in:
@@ -68,26 +68,36 @@ class ChatroomListKnownFeedFilter(val account: Account) : AdditiveFeedFilter<Not
|
|||||||
var myNewList = oldList
|
var myNewList = oldList
|
||||||
|
|
||||||
newRelevantPublicMessages.forEach { newNotePair ->
|
newRelevantPublicMessages.forEach { newNotePair ->
|
||||||
|
var hasUpdated = false
|
||||||
oldList.forEach { oldNote ->
|
oldList.forEach { oldNote ->
|
||||||
if (
|
if (newNotePair.key == oldNote.channelHex()) {
|
||||||
(newNotePair.key == oldNote.channelHex()) && (newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)
|
hasUpdated = true
|
||||||
) {
|
if ((newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)) {
|
||||||
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasUpdated) {
|
||||||
|
myNewList = myNewList.plus(newNotePair.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
newRelevantPrivateMessages.forEach { newNotePair ->
|
newRelevantPrivateMessages.forEach { newNotePair ->
|
||||||
|
var hasUpdated = false
|
||||||
oldList.forEach { oldNote ->
|
oldList.forEach { oldNote ->
|
||||||
val oldRoom = (oldNote.event as? ChatroomKeyable)?.chatroomKey(me.pubkeyHex)
|
val oldRoom = (oldNote.event as? ChatroomKeyable)?.chatroomKey(me.pubkeyHex)
|
||||||
|
|
||||||
if (
|
if (newNotePair.key == oldRoom) {
|
||||||
(newNotePair.key == oldRoom) && (newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)
|
hasUpdated = true
|
||||||
) {
|
if ((newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)) {
|
||||||
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasUpdated) {
|
||||||
|
myNewList = myNewList.plus(newNotePair.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sort(myNewList.toSet()).take(1000)
|
sort(myNewList.toSet()).take(1000)
|
||||||
}
|
}
|
||||||
|
@@ -53,16 +53,21 @@ class ChatroomListNewFeedFilter(val account: Account) : AdditiveFeedFilter<Note>
|
|||||||
var myNewList = oldList
|
var myNewList = oldList
|
||||||
|
|
||||||
newRelevantPrivateMessages.forEach { newNotePair ->
|
newRelevantPrivateMessages.forEach { newNotePair ->
|
||||||
|
var hasUpdated = false
|
||||||
oldList.forEach { oldNote ->
|
oldList.forEach { oldNote ->
|
||||||
val oldRoom = (oldNote.event as? ChatroomKeyable)?.chatroomKey(me.pubkeyHex)
|
val oldRoom = (oldNote.event as? ChatroomKeyable)?.chatroomKey(me.pubkeyHex)
|
||||||
|
|
||||||
if (
|
if (newNotePair.key == oldRoom) {
|
||||||
(newNotePair.key == oldRoom) && (newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)
|
hasUpdated = true
|
||||||
) {
|
if ((newNotePair.value.createdAt() ?: 0) > (oldNote.createdAt() ?: 0)) {
|
||||||
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
myNewList = myNewList.updated(oldNote, newNotePair.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!hasUpdated) {
|
||||||
|
myNewList = myNewList.plus(newNotePair.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sort(myNewList.toSet()).take(1000)
|
sort(myNewList.toSet()).take(1000)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user