Skip to content

Commit f7de115

Browse files
Fix/contact delete qa (#1093)
* SES-3716 - showing empty state when back from home * SES-3674 - We should not assumed we have approved or "Sent in a thread" when we get a request response This fixes an issue where person A sends a message request to person B Then person A deletes person B Then person B accepts the request from person A. This should create a message request for person A, not a regular conersation.
1 parent ae4d387 commit f7de115

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ open class Storage @Inject constructor(
16391639
profileManager.setUnidentifiedAccessMode(context, sender, Recipient.UnidentifiedAccessMode.UNKNOWN)
16401640
}
16411641
}
1642-
threadDatabase.setHasSent(threadId, true)
1642+
16431643
val mappingDb = blindedIdMappingDatabase
16441644
val mappings = mutableMapOf<String, BlindedIdMapping>()
16451645
threadDatabase.readerFor(threadDatabase.conversationList).use { reader ->
@@ -1674,7 +1674,6 @@ open class Storage @Inject constructor(
16741674
alreadyApprovedMe = it.contacts.get(sender.address.toString())?.approvedMe ?: false
16751675
}
16761676

1677-
setRecipientApproved(sender, true)
16781677
setRecipientApprovedMe(sender, true)
16791678

16801679
// only show the message if wasn't already approvedMe before

app/src/main/java/org/thoughtcrime/securesms/home/HomeActivity.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
200200
binding.globalSearchInputLayout.listener = this
201201
homeAdapter.setHasStableIds(true)
202202
homeAdapter.glide = glide
203-
binding.searchContactsRecyclerView.adapter = homeAdapter
203+
binding.conversationsRecyclerView.adapter = homeAdapter
204204
binding.globalSearchRecycler.adapter = globalSearchAdapter
205205

206206
binding.configOutdatedView.setOnClickListener {
@@ -237,7 +237,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
237237
homeViewModel.data
238238
.filterNotNull() // We don't actually want the null value here as it indicates a loading state (maybe we need a loading state?)
239239
.collectLatest { data ->
240-
val manager = binding.searchContactsRecyclerView.layoutManager as LinearLayoutManager
240+
val manager = binding.conversationsRecyclerView.layoutManager as LinearLayoutManager
241241
val firstPos = manager.findFirstCompletelyVisibleItemPosition()
242242
val offsetTop = if(firstPos >= 0) {
243243
manager.findViewByPosition(firstPos)?.let { view ->
@@ -429,14 +429,15 @@ class HomeActivity : ScreenLockActionBarActivity(),
429429

430430
binding.searchToolbar.isVisible = isShown
431431
binding.sessionToolbar.isVisible = !isShown
432-
binding.searchContactsRecyclerView.isVisible = !isShown
432+
binding.conversationsRecyclerView.isVisible = !isShown
433433
binding.seedReminderView.isVisible = !TextSecurePreferences.getHasViewedSeed(this) && !isShown
434434
binding.globalSearchRecycler.isVisible = isShown
435435
binding.conversationListContainer.isVisible = !isShown
436436
if(isShown){
437437
binding.newConversationButton.animate().cancel()
438438
binding.newConversationButton.isVisible = false
439439
} else {
440+
updateEmptyState()
440441
binding.newConversationButton.apply {
441442
alpha = 0.0f
442443
visibility = View.VISIBLE
@@ -482,8 +483,8 @@ class HomeActivity : ScreenLockActionBarActivity(),
482483

483484
// region Updating
484485
private fun updateEmptyState() {
485-
val threadCount = (binding.searchContactsRecyclerView.adapter)!!.itemCount
486-
binding.emptyStateContainer.isVisible = threadCount == 0 && binding.searchContactsRecyclerView.isVisible
486+
val threadCount = binding.conversationsRecyclerView.adapter?.itemCount ?: 0
487+
binding.emptyStateContainer.isVisible = threadCount == 0 && binding.conversationsRecyclerView.isVisible
487488
}
488489

489490
@Subscribe(threadMode = ThreadMode.MAIN)
@@ -606,7 +607,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
606607
storage.setBlocked(listOf(thread.recipient), true)
607608

608609
withContext(Dispatchers.Main) {
609-
binding.searchContactsRecyclerView.adapter!!.notifyDataSetChanged()
610+
binding.conversationsRecyclerView.adapter!!.notifyDataSetChanged()
610611
}
611612
}
612613
// Block confirmation toast added as per SS-64
@@ -625,7 +626,7 @@ class HomeActivity : ScreenLockActionBarActivity(),
625626
lifecycleScope.launch(Dispatchers.Default) {
626627
storage.setBlocked(listOf(thread.recipient), false)
627628
withContext(Dispatchers.Main) {
628-
binding.searchContactsRecyclerView.adapter!!.notifyDataSetChanged()
629+
binding.conversationsRecyclerView.adapter!!.notifyDataSetChanged()
629630
}
630631
}
631632
}

app/src/main/res/layout/activity_home.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
android:id="@+id/conversationListContainer">
159159

160160
<androidx.recyclerview.widget.RecyclerView
161-
android:id="@+id/searchContactsRecyclerView"
161+
android:id="@+id/conversationsRecyclerView"
162162
android:layout_width="match_parent"
163163
android:layout_height="match_parent"
164164
android:clipToPadding="false"

0 commit comments

Comments
 (0)