set last clear date to time of last message

This commit is contained in:
Daniel Gultsch 2017-03-07 11:45:35 +01:00
parent 5fae9465d1
commit 3c951ce2cd

View file

@ -3630,9 +3630,15 @@ public class XmppConnectionService extends Service {
} }
public void clearConversationHistory(final Conversation conversation) { public void clearConversationHistory(final Conversation conversation) {
long clearDate;
if (conversation.countMessages() > 0) {
clearDate = conversation.getLatestMessage().getTimeSent() + 1000;
} else {
clearDate = System.currentTimeMillis();
}
conversation.clearMessages(); conversation.clearMessages();
conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam
conversation.setLastClearHistory(System.currentTimeMillis()); conversation.setLastClearHistory(clearDate);
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {