mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Fix merge master to dev for release-1.18.3
This commit is contained in:
parent
ca9786a43d
commit
193381e193
@ -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? {
|
||||
|
@ -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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user