diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/EmailAndNameWorker.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/EmailAndNameWorker.kt index 1f83d69295..06aa5712e3 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/EmailAndNameWorker.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/workmanager/EmailAndNameWorker.kt @@ -41,7 +41,7 @@ class EmailAndNameWorker(context: Context, params: WorkerParameters) : BaseWorke for (i in emails.indices) { val email = emails[i].lowercase() - val name = names[i] + val name = names[i].takeIf { it.isNotEmpty() } val recipientEntity = recipientDao.getRecipientByEmailSuspend(email) if (recipientEntity != null) { if (recipientEntity.name.isNullOrEmpty()) { @@ -60,7 +60,7 @@ class EmailAndNameWorker(context: Context, params: WorkerParameters) : BaseWorke const val EXTRA_KEY_NAMES = BuildConfig.APPLICATION_ID + ".EXTRA_KEY_NAMES" const val GROUP_UNIQUE_TAG = BuildConfig.APPLICATION_ID + ".UPDATE_EMAIL_AND_NAME" - fun enqueue(context: Context, emailAndNamePairs: List>) { + fun enqueue(context: Context, emailAndNamePairs: List>) { var i = 0 val stepValue = 50 while (i < emailAndNamePairs.size) { diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt index d7cb7690bb..a5a96307fe 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/util/GeneralUtil.kt @@ -597,7 +597,7 @@ class GeneralUtil { val isSentFolder = imapFolder?.attributes?.contains("\\Sent") != false if (isSentFolder) { - val emailAndNamePairs = mutableListOf>() + val emailAndNamePairs = mutableListOf>() for (message in messages) { emailAndNamePairs.addAll(getEmailAndNamePairs(message)) } @@ -615,9 +615,7 @@ class GeneralUtil { * This information will be retrieved from "to" and "cc" headers. * * @param msg The input [jakarta.mail.Message]. - * @return [List] of [Pair] objects, which contains information - * about - * emails and names. + * @return [List] of [Pair] objects, which contains information about emails and names. * @throws MessagingException when retrieve information about recipients. */ private fun getEmailAndNamePairs(msg: Message): List> { @@ -627,7 +625,7 @@ class GeneralUtil { if (addressesTo != null) { for (address in addressesTo) { val internetAddress = address as InternetAddress - pairs.add(Pair(internetAddress.address, internetAddress.personal)) + pairs.add(Pair(internetAddress.address, internetAddress.personal ?: "")) } } @@ -635,7 +633,7 @@ class GeneralUtil { if (addressesCC != null) { for (address in addressesCC) { val internetAddress = address as InternetAddress - pairs.add(Pair(internetAddress.address, internetAddress.personal)) + pairs.add(Pair(internetAddress.address, internetAddress.personal ?: "")) } }