Fix cursor crash in ConversationSettings.

Best way to fix a cursor crash it to... stop using cursors.

Fairly confident the crash was caused by us closing the cursor while it
was read. And there just isn't a good way to avoid that with how it was
written. So this ended up being a great excuse to move over to models.
This commit is contained in:
Greyson Parrelli
2023-11-02 11:57:58 -04:00
parent b5c1051506
commit 99d0ee6725
7 changed files with 52 additions and 56 deletions

View File

@@ -143,13 +143,19 @@ class MediaTable internal constructor(context: Context?, databaseHelper: SignalD
}
}
fun getGalleryMediaForThread(threadId: Long, sorting: Sorting): Cursor {
val query = if (FeatureFlags.instantVideoPlayback()) {
@JvmOverloads
fun getGalleryMediaForThread(threadId: Long, sorting: Sorting, limit: Int = 0): Cursor {
var query = if (FeatureFlags.instantVideoPlayback()) {
sorting.applyToQuery(applyEqualityOperator(threadId, GALLERY_MEDIA_QUERY_INCLUDING_TEMP_VIDEOS))
} else {
sorting.applyToQuery(applyEqualityOperator(threadId, GALLERY_MEDIA_QUERY))
}
val args = arrayOf(threadId.toString() + "")
if (limit > 0) {
query = "$query LIMIT $limit"
}
return readableDatabase.rawQuery(query, args)
}