Avoid resetting conversation name
This commit is contained in:
parent
9dc5b30e80
commit
83cdf0f623
|
@ -307,10 +307,8 @@ class MainActivity : SimpleActivity() {
|
|||
}
|
||||
if (conv != null) {
|
||||
val lastModified = maxOf(cachedConv.date, conv.date)
|
||||
val usesCustomTitle = cachedConv.usesCustomTitle
|
||||
val title = if (usesCustomTitle) cachedConv.title else conv.title
|
||||
val conversation = conv.copy(date = lastModified, title = title, usesCustomTitle = usesCustomTitle)
|
||||
conversationsDB.insertOrUpdate(conversation)
|
||||
val conversation = conv.copy(date = lastModified)
|
||||
insertOrUpdateConversation(conversation)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -824,7 +824,7 @@ fun Context.updateLastConversationMessage(threadId: Long) {
|
|||
try {
|
||||
contentResolver.delete(uri, selection, selectionArgs)
|
||||
val newConversation = getConversations(threadId)[0]
|
||||
conversationsDB.insertOrUpdate(newConversation)
|
||||
insertOrUpdateConversation(newConversation)
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
|
@ -878,6 +878,18 @@ fun Context.subscriptionManagerCompat(): SubscriptionManager {
|
|||
return getSystemService(SubscriptionManager::class.java)
|
||||
}
|
||||
|
||||
fun Context.insertOrUpdateConversation(conversation: Conversation) {
|
||||
val cachedConv = conversationsDB.getConversationWithThreadId(conversation.threadId)
|
||||
val updatedConv = if (cachedConv != null) {
|
||||
val usesCustomTitle = cachedConv.usesCustomTitle
|
||||
val title = if (usesCustomTitle) cachedConv.title else conversation.title
|
||||
conversation.copy(title = title, usesCustomTitle = usesCustomTitle)
|
||||
} else {
|
||||
conversation
|
||||
}
|
||||
conversationsDB.insertOrUpdate(updatedConv)
|
||||
}
|
||||
|
||||
fun Context.renameConversation(conversation: Conversation, newTitle: String): Conversation {
|
||||
val updatedConv = conversation.copy(title = newTitle, usesCustomTitle = true)
|
||||
try {
|
||||
|
|
|
@ -41,7 +41,7 @@ class MmsReceiver : com.klinker.android.send_message.MmsReceivedReceiver() {
|
|||
context.showReceivedMessageNotification(address, mms.body, mms.threadId, glideBitmap)
|
||||
val conversation = context.getConversations(mms.threadId).firstOrNull() ?: return@post
|
||||
ensureBackgroundThread {
|
||||
context.conversationsDB.insertOrUpdate(conversation)
|
||||
context.insertOrUpdateConversation(conversation)
|
||||
context.updateUnreadCountBadge(context.conversationsDB.getUnreadConversations())
|
||||
refreshMessages()
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ class SmsReceiver : BroadcastReceiver() {
|
|||
|
||||
val conversation = context.getConversations(threadId).firstOrNull() ?: return@ensureBackgroundThread
|
||||
try {
|
||||
context.conversationsDB.insertOrUpdate(conversation)
|
||||
context.insertOrUpdateConversation(conversation)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue