#1079 - Fix composing new conversations not working on Huawei devices

This commit is contained in:
moezbhatti
2018-11-18 18:04:52 -05:00
parent 41933cef4a
commit e610a373ca
3 changed files with 66 additions and 27 deletions
@@ -62,7 +62,8 @@ class MessageRepositoryImpl @Inject constructor(
private val context: Context,
private val messageIds: KeyManager,
private val imageRepository: ImageRepository,
private val prefs: Preferences) : MessageRepository {
private val prefs: Preferences,
private val syncRepository: SyncRepository) : MessageRepository {
override fun getMessages(threadId: Long, query: String): RealmResults<Message> {
return Realm.getDefaultInstance()
@@ -336,6 +337,13 @@ class MessageRepositoryImpl @Inject constructor(
realm.executeTransaction { managedMessage?.takeIf { it.isValid }?.contentId = uri.lastPathSegment.toLong() }
realm.close()
// On some devices, we can't obtain a threadId until after the first message is sent in a
// conversation. In this case, we need to update the message's threadId after it gets added
// to the native ContentProvider
if (threadId == 0L) {
uri?.let(syncRepository::syncMessage)
}
return message
}