use clock

This commit is contained in:
Felicio Mununga 2022-06-09 20:32:36 +02:00
parent d6c1ff0450
commit ca66e8b132
No known key found for this signature in database
GPG Key ID: 0EB8D75C775AB6F1
2 changed files with 5 additions and 9 deletions

View File

@ -1,11 +1,6 @@
// todo: handle updates together with fetching history (chat messages)
// todo: handle diff waku messages on diff topics
// todo?: already received (by messageId or event)
// todo: use clock for sorting
// todo: use Map
// todo: write class for channels
// todo: fetch all history until Map; remove end param
// todo: handle
// todo: tests

View File

@ -202,6 +202,10 @@ export class Community {
communityMetadata: CommunityMetadataType
) => {
if (this.communityMetadata) {
if (this.communityMetadata.clock > communityMetadata.clock) {
return
}
// Channels
const removedChats = difference(
Object.keys(this.communityMetadata.chats),
@ -245,10 +249,7 @@ export class Community {
break
}
if (
new Date(Number(_message.timestamp)) <=
new Date(Number(chatMessage.timestamp))
) {
if (_message.clock <= chatMessage.clock) {
break
}