Avoid resetting conversation name
This commit is contained in:
parent
9dc5b30e80
commit
83cdf0f623
4 changed files with 17 additions and 7 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue