mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Handle case where there are no messages
This commit is contained in:
parent
c4309c9fba
commit
35d176c71e
@ -325,9 +325,12 @@ public class MmsSmsDatabase extends Database {
|
|||||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||||
|
|
||||||
try (Cursor cursor = queryTables(PROJECTION, selection, order, "1")) {
|
try (Cursor cursor = queryTables(PROJECTION, selection, order, "1")) {
|
||||||
cursor.moveToFirst();
|
if (cursor.moveToFirst()) {
|
||||||
return cursor.getLong(cursor.getColumnIndexOrThrow(MmsSmsColumns.NORMALIZED_DATE_SENT));
|
return cursor.getLong(cursor.getColumnIndexOrThrow(MmsSmsColumns.NORMALIZED_DATE_SENT));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cursor getUnread() {
|
public Cursor getUnread() {
|
||||||
|
@ -939,7 +939,9 @@ public class ThreadDatabase extends Database {
|
|||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
|
MmsSmsDatabase mmsSmsDatabase = DatabaseComponent.get(context).mmsSmsDatabase();
|
||||||
long messageTimestamp = mmsSmsDatabase.getLastMessageTimestamp(threadId);
|
long messageTimestamp = mmsSmsDatabase.getLastMessageTimestamp(threadId);
|
||||||
lastMessage = mmsSmsDatabase.getMessageForTimestamp(messageTimestamp);
|
if (messageTimestamp > 0) {
|
||||||
|
lastMessage = mmsSmsDatabase.getMessageForTimestamp(messageTimestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ThreadRecord(body, snippetUri, lastMessage, recipient, date, count,
|
return new ThreadRecord(body, snippetUri, lastMessage, recipient, date, count,
|
||||||
|
Loading…
Reference in New Issue
Block a user