mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Merge branch 'message-tracked-event' into 'master'
Implement and use new message tracked event See merge request briar/briar!1541
This commit is contained in:
@@ -40,10 +40,10 @@ public class ContactListItem extends ContactItem
|
||||
item.unread, item.timestamp);
|
||||
}
|
||||
|
||||
ContactListItem(ContactListItem item, ConversationMessageHeader h) {
|
||||
ContactListItem(ContactListItem item, long timestamp, boolean read) {
|
||||
this(item.getContact(), item.getAuthorInfo(), item.isConnected(), false,
|
||||
h.isRead() ? item.unread : item.unread + 1,
|
||||
Math.max(h.getTimestamp(), item.timestamp));
|
||||
read ? item.unread : item.unread + 1,
|
||||
Math.max(timestamp, item.timestamp));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager;
|
||||
import org.briarproject.briar.api.conversation.ConversationMessageHeader;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
|
||||
import org.briarproject.briar.api.conversation.event.ConversationMessageTrackedEvent;
|
||||
import org.briarproject.briar.api.identity.AuthorInfo;
|
||||
import org.briarproject.briar.api.identity.AuthorManager;
|
||||
|
||||
@@ -131,13 +132,14 @@ public class ContactsViewModel extends DbViewModel implements EventListener {
|
||||
} else if (e instanceof ContactRemovedEvent) {
|
||||
LOG.info("Contact removed, removing item");
|
||||
removeItem(((ContactRemovedEvent) e).getContactId());
|
||||
} else if (e instanceof ConversationMessageReceivedEvent) {
|
||||
LOG.info("Conversation message received, updating item");
|
||||
ConversationMessageReceivedEvent<?> p =
|
||||
(ConversationMessageReceivedEvent<?>) e;
|
||||
ConversationMessageHeader h = p.getMessageHeader();
|
||||
updateItem(p.getContactId(), item -> new ContactListItem(item, h),
|
||||
true);
|
||||
} else if (e instanceof ConversationMessageTrackedEvent) {
|
||||
LOG.info("Conversation message tracked, updating item");
|
||||
ConversationMessageTrackedEvent p =
|
||||
(ConversationMessageTrackedEvent) e;
|
||||
long timestamp = p.getTimestamp();
|
||||
boolean read = p.getRead();
|
||||
updateItem(p.getContactId(),
|
||||
item -> new ContactListItem(item, timestamp, read), true);
|
||||
} else if (e instanceof AvatarUpdatedEvent) {
|
||||
AvatarUpdatedEvent a = (AvatarUpdatedEvent) e;
|
||||
updateItem(a.getContactId(), item -> new ContactListItem(item,
|
||||
|
||||
Reference in New Issue
Block a user