From 3c951ce2cd06cd7362ed32273789779d0966c091 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 7 Mar 2017 11:45:35 +0100 Subject: [PATCH] set last clear date to time of last message --- .../conversations/services/XmppConnectionService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 9ace7c18e..aa8618adb 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -3630,9 +3630,15 @@ public class XmppConnectionService extends Service { } public void clearConversationHistory(final Conversation conversation) { + long clearDate; + if (conversation.countMessages() > 0) { + clearDate = conversation.getLatestMessage().getTimeSent() + 1000; + } else { + clearDate = System.currentTimeMillis(); + } conversation.clearMessages(); conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam - conversation.setLastClearHistory(System.currentTimeMillis()); + conversation.setLastClearHistory(clearDate); Runnable runnable = new Runnable() { @Override public void run() {