mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 15:13:50 +00:00
Handle quote position task finishing after fragment detaches.
There's a chance that the AsyncTask that retrieves a quoted message's position could finish after the fragment is detached, which would cause a crash. I've changed it so if this case occurs, the result is ignored. Also, I noticed that when searching the message table, if a quote can't be found, we'd end up traversing the entire table. To prevent this from taking forever on large message tables, I've limited it to searchin only what is currently present in the adapter. Fixes #7756
This commit is contained in:
@@ -158,11 +158,11 @@ public class MmsSmsDatabase extends Database {
|
||||
DatabaseFactory.getMmsDatabase(context).incrementReceiptCount(syncMessageId, timestamp, false, true);
|
||||
}
|
||||
|
||||
public int getQuotedMessagePosition(long threadId, long quoteId, @NonNull Address address) {
|
||||
public int getQuotedMessagePosition(long threadId, long quoteId, @NonNull Address address, int limit) {
|
||||
String order = MmsSmsColumns.NORMALIZED_DATE_RECEIVED + " DESC";
|
||||
String selection = MmsSmsColumns.THREAD_ID + " = " + threadId;
|
||||
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, null)) {
|
||||
try (Cursor cursor = queryTables(new String[]{ MmsSmsColumns.NORMALIZED_DATE_SENT, MmsSmsColumns.ADDRESS }, selection, order, String.valueOf(limit))) {
|
||||
String serializedAddress = address.serialize();
|
||||
boolean isOwnNumber = Util.isOwnNumber(context, address);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user