mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-03 15:45:38 +00:00
Open group avatar DB record cleanup on deletion.
General cleanup.
This commit is contained in:
parent
70815e61d0
commit
2920e3e528
@ -340,20 +340,18 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
val threadID = thread.threadId
|
val threadID = thread.threadId
|
||||||
val recipient = thread.recipient
|
val recipient = thread.recipient
|
||||||
val threadDB = DatabaseFactory.getThreadDatabase(this)
|
val threadDB = DatabaseFactory.getThreadDatabase(this)
|
||||||
val deleteThread = object : Runnable {
|
val deleteThread = Runnable {
|
||||||
|
AsyncTask.execute {
|
||||||
override fun run() {
|
val publicChat = DatabaseFactory.getLokiThreadDatabase(this@HomeActivity).getPublicChat(threadID)
|
||||||
AsyncTask.execute {
|
if (publicChat != null) {
|
||||||
val publicChat = DatabaseFactory.getLokiThreadDatabase(this@HomeActivity).getPublicChat(threadID)
|
val apiDB = DatabaseFactory.getLokiAPIDatabase(this@HomeActivity)
|
||||||
if (publicChat != null) {
|
apiDB.removeLastMessageServerID(publicChat.channel, publicChat.server)
|
||||||
val apiDB = DatabaseFactory.getLokiAPIDatabase(this@HomeActivity)
|
apiDB.removeLastDeletionServerID(publicChat.channel, publicChat.server)
|
||||||
apiDB.removeLastMessageServerID(publicChat.channel, publicChat.server)
|
apiDB.clearOpenGroupAvatarURL(publicChat.channel, publicChat.server)
|
||||||
apiDB.removeLastDeletionServerID(publicChat.channel, publicChat.server)
|
ApplicationContext.getInstance(this@HomeActivity).publicChatAPI!!.leave(publicChat.channel, publicChat.server)
|
||||||
ApplicationContext.getInstance(this@HomeActivity).publicChatAPI!!.leave(publicChat.channel, publicChat.server)
|
|
||||||
}
|
|
||||||
threadDB.deleteConversation(threadID)
|
|
||||||
ApplicationContext.getInstance(this@HomeActivity).messageNotifier.updateNotification(this@HomeActivity)
|
|
||||||
}
|
}
|
||||||
|
threadDB.deleteConversation(threadID)
|
||||||
|
ApplicationContext.getInstance(this@HomeActivity).messageNotifier.updateNotification(this@HomeActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val dialogMessage = if (recipient.isGroupRecipient) R.string.activity_home_leave_group_dialog_message else R.string.activity_home_delete_conversation_dialog_message
|
val dialogMessage = if (recipient.isGroupRecipient) R.string.activity_home_leave_group_dialog_message else R.string.activity_home_delete_conversation_dialog_message
|
||||||
|
@ -355,13 +355,19 @@ class LokiAPIDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(
|
|||||||
}?.toString()
|
}?.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setOpenGroupAvatarURL(url: String, group: Long, server: String) {
|
override fun setOpenGroupAvatarURL(group: Long, server: String, url: String) {
|
||||||
val database = databaseHelper.writableDatabase
|
val database = databaseHelper.writableDatabase
|
||||||
val index = "$server.$group"
|
val index = "$server.$group"
|
||||||
val row = wrap(mapOf(publicChatID to index, openGroupAvatar to url))
|
val row = wrap(mapOf(publicChatID to index, openGroupAvatar to url))
|
||||||
database.insertOrUpdate(openGroupAvatarCacheTable, row, "$publicChatID = ?", wrap(index))
|
database.insertOrUpdate(openGroupAvatarCacheTable, row, "$publicChatID = ?", wrap(index))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearOpenGroupAvatarURL(group: Long, server: String): Boolean {
|
||||||
|
val database = databaseHelper.writableDatabase
|
||||||
|
val index = "$server.$group"
|
||||||
|
return database.delete(openGroupAvatarCacheTable, "$publicChatID == ?", arrayOf(index)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
// region Deprecated
|
// region Deprecated
|
||||||
override fun getDeviceLinks(publicKey: String): Set<DeviceLink> {
|
override fun getDeviceLinks(publicKey: String): Set<DeviceLink> {
|
||||||
return setOf()
|
return setOf()
|
||||||
|
@ -72,37 +72,27 @@ class ProfilePictureView : RelativeLayout {
|
|||||||
return recipient.isOpenGroupRecipient &&
|
return recipient.isOpenGroupRecipient &&
|
||||||
DatabaseFactory.getGroupDatabase(context).hasAvatar(recipient.address.toString())
|
DatabaseFactory.getGroupDatabase(context).hasAvatar(recipient.address.toString())
|
||||||
}
|
}
|
||||||
if (recipient.isGroupRecipient) {
|
if (recipient.isGroupRecipient && !isOpenGroupWithAvatar(recipient)) {
|
||||||
if ("Session Public Chat" == recipient.name) {
|
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
||||||
publicKey = ""
|
users.remove(TextSecurePreferences.getLocalNumber(context))
|
||||||
displayName = ""
|
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
||||||
additionalPublicKey = null
|
if (masterPublicKey != null) {
|
||||||
isRSSFeed = true
|
users.remove(masterPublicKey)
|
||||||
} else if (isOpenGroupWithAvatar(recipient)) {
|
|
||||||
publicKey = recipient.address.toString()
|
|
||||||
displayName = getUserDisplayName(publicKey)
|
|
||||||
additionalPublicKey = null
|
|
||||||
isRSSFeed = false
|
|
||||||
} else {
|
|
||||||
val users = MentionsManager.shared.userPublicKeyCache[threadID]?.toMutableList() ?: mutableListOf()
|
|
||||||
users.remove(TextSecurePreferences.getLocalNumber(context))
|
|
||||||
val masterPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context)
|
|
||||||
if (masterPublicKey != null) {
|
|
||||||
users.remove(masterPublicKey)
|
|
||||||
}
|
|
||||||
val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability
|
|
||||||
if (users.count() == 1) {
|
|
||||||
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
|
||||||
randomUsers.add(0, userPublicKey) // Ensure the current user is at the back visually
|
|
||||||
}
|
|
||||||
val pk = randomUsers.getOrNull(0) ?: ""
|
|
||||||
publicKey = pk
|
|
||||||
displayName = getUserDisplayName(pk)
|
|
||||||
val apk = randomUsers.getOrNull(1) ?: ""
|
|
||||||
additionalPublicKey = apk
|
|
||||||
additionalDisplayName = getUserDisplayName(apk)
|
|
||||||
isRSSFeed = recipient.name == "Loki News" || recipient.name == "Session Updates"
|
|
||||||
}
|
}
|
||||||
|
val randomUsers = users.sorted().toMutableList() // Sort to provide a level of stability
|
||||||
|
if (users.count() == 1) {
|
||||||
|
val userPublicKey = TextSecurePreferences.getLocalNumber(context)
|
||||||
|
randomUsers.add(0, userPublicKey) // Ensure the current user is at the back visually
|
||||||
|
}
|
||||||
|
val pk = randomUsers.getOrNull(0) ?: ""
|
||||||
|
publicKey = pk
|
||||||
|
displayName = getUserDisplayName(pk)
|
||||||
|
val apk = randomUsers.getOrNull(1) ?: ""
|
||||||
|
additionalPublicKey = apk
|
||||||
|
additionalDisplayName = getUserDisplayName(apk)
|
||||||
|
isRSSFeed = recipient.name == "Loki News" ||
|
||||||
|
recipient.name == "Session Updates" ||
|
||||||
|
recipient.name == "Session Public Chat"
|
||||||
} else {
|
} else {
|
||||||
publicKey = recipient.address.toString()
|
publicKey = recipient.address.toString()
|
||||||
displayName = getUserDisplayName(publicKey)
|
displayName = getUserDisplayName(publicKey)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user