Removed custom profile avatar url table since signal already has an existing one.

Clean
This commit is contained in:
Mikunj
2019-11-26 09:55:08 +11:00
parent 5a4b619c9d
commit 06f75859fa
3 changed files with 15 additions and 46 deletions

View File

@@ -25,9 +25,6 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
private val serverDisplayNameTable = "loki_user_server_display_name_database"
private val serverID = "server_id"
@JvmStatic val createServerDisplayNameTableCommand = "CREATE TABLE $serverDisplayNameTable ($hexEncodedPublicKey TEXT, $serverID TEXT, $displayName TEXT, PRIMARY KEY ($hexEncodedPublicKey, $serverID));"
// Profile Avatar URL cache
private val profileAvatarUrlTable = "loki_user_profile_avatar_url_database"
@JvmStatic val createProfileAvatarUrlTableCommand = "CREATE TABLE $profileAvatarUrlTable ($hexEncodedPublicKey TEXT PRIMARY KEY, $profileAvatarUrl TEXT);"
}
override fun getDisplayName(hexEncodedPublicKey: String): String? {
@@ -72,25 +69,10 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database
}
override fun getProfileAvatarUrl(hexEncodedPublicKey: String): String? {
if (hexEncodedPublicKey == TextSecurePreferences.getLocalNumber(context)) {
return TextSecurePreferences.getProfileAvatarUrl(context)
return if (hexEncodedPublicKey == TextSecurePreferences.getLocalNumber(context)) {
TextSecurePreferences.getProfileAvatarUrl(context)
} else {
val database = databaseHelper.readableDatabase
return database.get(profileAvatarUrlTable, "${Companion.hexEncodedPublicKey} = ?", arrayOf( hexEncodedPublicKey )) { cursor ->
cursor.getString(cursor.getColumnIndexOrThrow(profileAvatarUrl))
}
Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false).resolve().profileAvatar
}
}
//TODO figure out what to do with Recipient
/*
fun setProfileAvatarUrl(hexEncodedPublicKey: String, profileAvatarUrl: String) {
val database = databaseHelper.writableDatabase
val row = ContentValues(2)
row.put(Companion.hexEncodedPublicKey, hexEncodedPublicKey)
row.put(Companion.profileAvatarUrl, profileAvatarUrl)
database.insertOrUpdate(profileAvatarUrlTable, row, "${Companion.hexEncodedPublicKey} = ?", arrayOf( hexEncodedPublicKey ))
Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false).notifyListeners()
}
*/
}