From afd240dcce430969158c20070ccacca7deecb7ef Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 7 May 2024 10:58:41 +0930 Subject: [PATCH] Simplify HomeActivity --- .../securesms/home/HomeActivity.kt | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt index fb6a501dbc..8443181c5e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt @@ -300,9 +300,8 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), } val unreadThreadMap = result.messages - .groupBy { it.threadId }.keys - .map { it to mmsSmsDatabase.getUnreadCount(it) } - .toMap() + .map { it.threadId }.toSet() + .associateWith { mmsSmsDatabase.getUnreadCount(it) } val messageResults: MutableList = result.messages .map { messageResult -> @@ -330,11 +329,9 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), .request(Manifest.permission.POST_NOTIFICATIONS) .execute() } - configFactory.user?.let { user -> - if (!user.isBlockCommunityMessageRequestsSet()) { - user.setCommunityMessageRequests(false) - } - } + configFactory.user + ?.takeUnless { it.isBlockCommunityMessageRequestsSet() } + ?.setCommunityMessageRequests(false) } } @@ -441,7 +438,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), Locale.getDefault(), threadDb.latestUnapprovedConversationTimestamp ) - root.setOnClickListener { showMessageRequests() } + root.setOnClickListener { push() } root.setOnLongClickListener { hideMessageRequests(); true } root.layoutParams = RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT) val hadHeader = homeAdapter.hasHeaderView() @@ -770,11 +767,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(), show(intent, isForResult = true) } - private fun showMessageRequests() { - val intent = Intent(this, MessageRequestsActivity::class.java) - push(intent) - } - private fun hideMessageRequests() { showSessionDialog { text(getString(R.string.hide_message_requests))