From d84373fa192c45e933ae77d920edacfa05cac018 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Fri, 4 Sep 2020 17:22:41 +1000 Subject: [PATCH] Deal with legacy display names --- .../securesms/loki/database/LokiUserDatabase.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/loki/database/LokiUserDatabase.kt b/src/org/thoughtcrime/securesms/loki/database/LokiUserDatabase.kt index 236ffb6fe3..634ec24556 100644 --- a/src/org/thoughtcrime/securesms/loki/database/LokiUserDatabase.kt +++ b/src/org/thoughtcrime/securesms/loki/database/LokiUserDatabase.kt @@ -33,8 +33,14 @@ class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database return TextSecurePreferences.getProfileName(context) } else { val database = databaseHelper.readableDatabase - return database.get(displayNameTable, "${Companion.publicKey} = ?", arrayOf( publicKey )) { cursor -> + val result = database.get(displayNameTable, "${Companion.publicKey} = ?", arrayOf( publicKey )) { cursor -> cursor.getString(cursor.getColumnIndexOrThrow(displayName)) + } ?: return null + val suffix = " (...${publicKey.substring(publicKey.count() - 8)})" + if (result.endsWith(suffix)) { + return result.substring(0..(result.count() - suffix.count())) + } else { + return result } } }