diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt index 371df34565..7b01eba71e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationAdapter.kt @@ -209,20 +209,6 @@ class ConversationAdapter( return messageDB.readerFor(cursor).current } - private fun getLastSentMessageId(cursor: Cursor): Long { - // If we don't move to first (or at least step backwards) we can step off the end of the - // cursor and any query will return an "Index = -1" error. - val cursorHasContent = cursor.moveToFirst() - if (cursorHasContent) { - val thisThreadId = cursor.getLong(4) // Column index 4 is "thread_id" - if (thisThreadId != -1L) { - val thisUsersSessionId = TextSecurePreferences.getLocalNumber(context) - return messageDB.getLastSentMessageFromSender(thisThreadId, thisUsersSessionId) - } - } - return -1L - } - override fun changeCursor(cursor: Cursor?) { super.changeCursor(cursor) @@ -243,11 +229,6 @@ class ConversationAdapter( toDeselect.iterator().forEach { (pos, record) -> onDeselect(record, pos) } - - // This value gets updated here ONLY when the cursor changes, and the value is then passed - // through to `VisibleMessageView.bind` each time we bind via `onBindItemViewHolder`, above. - // If there are no messages then lastSentMessageId is assigned the value -1L. - if (cursor != null) { lastSentMessageId = getLastSentMessageId(cursor) } } fun findLastSeenItemPosition(lastSeenTimestamp: Long): Int? { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java index f25689a380..c8f34c91e5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java @@ -163,53 +163,6 @@ public class MmsSmsDatabase extends Database { return null; } - public @Nullable MessageRecord getSentMessageFor(long timestamp, String serializedAuthor) { - // Early exit if the author is not us - boolean isOwnNumber = Util.isOwnNumber(context, serializedAuthor); - if (!isOwnNumber) { - Log.i(TAG, "Asked to find sent messages but provided author is not us - returning null."); - return null; - } - - try (Cursor cursor = queryTables(PROJECTION, MmsSmsColumns.NORMALIZED_DATE_SENT + " = " + timestamp, null, null)) { - MmsSmsDatabase.Reader reader = readerFor(cursor); - - MessageRecord messageRecord; - while ((messageRecord = reader.getNext()) != null) { - if (messageRecord.isOutgoing()) - { - return messageRecord; - } - } - } - Log.i(TAG, "Could not find any message sent from us at provided timestamp - returning null."); - return null; - } - - public MessageRecord getLastSentMessageRecordFromSender(long threadId, String serializedAuthor) { - // Early exit if the author is not us - boolean isOwnNumber = Util.isOwnNumber(context, serializedAuthor); - if (!isOwnNumber) { - Log.i(TAG, "Asked to find last sent message but provided author is not us - returning null."); - return null; - } - - String order = MmsSmsColumns.NORMALIZED_DATE_SENT + " DESC"; - String selection = MmsSmsColumns.THREAD_ID + " = " + threadId; - - // Try everything with resources so that they auto-close on end of scope - try (Cursor cursor = queryTables(PROJECTION, selection, order, null)) { - try (MmsSmsDatabase.Reader reader = readerFor(cursor)) { - MessageRecord messageRecord; - while ((messageRecord = reader.getNext()) != null) { - if (messageRecord.isOutgoing()) { return messageRecord; } - } - } - } - Log.i(TAG, "Could not find last sent message from us in given thread - returning null."); - return null; - } - public @Nullable MessageRecord getMessageFor(long timestamp, Address author) { return getMessageFor(timestamp, author.serialize()); }