From 87f2b2e1f30737084c53bdec168ad269da4ebadc Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 19 May 2017 16:41:29 +0200 Subject: [PATCH] feat(ui/modules/Linphone/Chat/IncomingMessage): display avatar if it exits one hour between two messages --- .../ui/modules/Linphone/Chat/IncomingMessage.qml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/linphone-desktop/ui/modules/Linphone/Chat/IncomingMessage.qml b/linphone-desktop/ui/modules/Linphone/Chat/IncomingMessage.qml index 608165a3b..3381e0b54 100644 --- a/linphone-desktop/ui/modules/Linphone/Chat/IncomingMessage.qml +++ b/linphone-desktop/ui/modules/Linphone/Chat/IncomingMessage.qml @@ -27,11 +27,17 @@ RowLayout { // The avatar is only visible for the first message of a incoming messages sequence. visible: { if (index <= 0) { - return true + return true // 1. First message, so visible. } - var entry = proxyModel.data(proxyModel.index(index - 1, 0)) - return entry.type !== ChatModel.MessageEntry || entry.isOutgoing + var previousEntry = proxyModel.data(proxyModel.index(index - 1, 0)) + + // 2. Previous entry is a call event. => Visible. + // 3. I have sent a message before me contact. => Visible. + // 4. One hour between two incoming message. => Visible. + return previousEntry.type !== ChatModel.MessageEntry || + previousEntry.isOutgoing || + $chatEntry.timestamp.getTime() - previousEntry.timestamp.getTime() > 3600 } } }