diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java index c525f05e7d..f4ab65f56c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -951,7 +951,13 @@ public class ThreadDatabase extends Database { readReceiptCount = 0; } - MessageRecord lastMessage = count > 0 ? getLastMessage(threadId) : null; + MessageRecord lastMessage = null; + + if (count > 0) { + MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase(); + long messageTimestamp = mmsSmsDatabase.getLastMessageTimestamp(threadId); + lastMessage = mmsSmsDatabase.getMessageForTimestamp(messageTimestamp); + } return new ThreadRecord(body, snippetUri, lastMessage, recipient, date, count, unreadCount, unreadMentionCount, threadId, deliveryReceiptCount, status, type, @@ -978,10 +984,4 @@ public class ThreadDatabase extends Database { } } } - - private MessageRecord getLastMessage(long threadId) { - MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase(); - long messageTimestamp = mmsSmsDatabase.getLastMessageTimestamp(threadId); - return mmsSmsDatabase.getMessageForTimestamp(messageTimestamp); - } }