From efec63e9799dc9b49ba5bbc92a69d8c22968dfc7 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 23 Sep 2021 12:02:46 +0100 Subject: [PATCH] documenting the getEmails function and lifting it out of the class as it's not directly tied to the class --- ...rSettingsNotificationPreferenceFragment.kt | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt index e13f68eb3a..fb30fae7e4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt @@ -155,13 +155,6 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor( } } - private fun Session.getEmailsWithPushInformation(): List> { - val emailPushers = getPushers().filter { it.kind == "email" } - return getThreePids() - .filterIsInstance() - .map { it to emailPushers.firstOrNull { pusher -> pusher.pushKey == it.email } } - } - private val batteryStartForActivityResult = registerStartForActivityResult { // Noop } @@ -400,3 +393,17 @@ private fun SwitchPreference.setTransactionalSwitchChangeListener(scope: Corouti true } } + +/** + * Fetches the current users 3pid emails and pairs them with pushers with same email as the push key. + * If no pusher is available for a given emails we can infer that push is not registered for the email. + * @return a list of ThreePid emails paired with its associated Pusher or null. + * @see ThreePid.Email + * @see Pusher + */ +private fun Session.getEmailsWithPushInformation(): List> { + val emailPushers = getPushers().filter { it.kind == "email" } + return getThreePids() + .filterIsInstance() + .map { it to emailPushers.firstOrNull { pusher -> pusher.pushKey == it.email } } +}