mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 02:55:23 +00:00
feat: add block to the delete all message requests, only if they're not open group inbox contacts
This commit is contained in:
parent
db18b156a3
commit
ad09888c80
@ -48,6 +48,7 @@ class MessageRequestsAdapter(
|
||||
private fun showPopupMenu(view: MessageRequestView) {
|
||||
val popupMenu = PopupMenu(ContextThemeWrapper(context, R.style.PopupMenu_MessageRequests), view)
|
||||
popupMenu.menuInflater.inflate(R.menu.menu_message_request, popupMenu.menu)
|
||||
popupMenu.menu.findItem(R.id.menu_block_message_request)?.isVisible = !view.thread!!.recipient.isOpenGroupInboxRecipient
|
||||
popupMenu.setOnMenuItemClickListener { menuItem ->
|
||||
if (menuItem.itemId == R.id.menu_delete_message_request) {
|
||||
listener.onDeleteConversationClick(view.thread!!)
|
||||
|
@ -25,8 +25,8 @@ class MessageRequestsViewModel @Inject constructor(
|
||||
repository.deleteMessageRequest(thread)
|
||||
}
|
||||
|
||||
fun clearAllMessageRequests() = viewModelScope.launch {
|
||||
repository.clearAllMessageRequests()
|
||||
fun clearAllMessageRequests(block: Boolean) = viewModelScope.launch {
|
||||
repository.clearAllMessageRequests(block)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.thoughtcrime.securesms.repository
|
||||
|
||||
import org.jetbrains.annotations.Contract
|
||||
import org.session.libsession.database.MessageDataProvider
|
||||
import org.session.libsession.messaging.messages.Destination
|
||||
import org.session.libsession.messaging.messages.control.MessageRequestResponse
|
||||
@ -65,7 +64,7 @@ interface ConversationRepository {
|
||||
|
||||
suspend fun deleteMessageRequest(thread: ThreadRecord): ResultOf<Unit>
|
||||
|
||||
suspend fun clearAllMessageRequests(): ResultOf<Unit>
|
||||
suspend fun clearAllMessageRequests(block: Boolean): ResultOf<Unit>
|
||||
|
||||
suspend fun acceptMessageRequest(threadId: Long, recipient: Recipient): ResultOf<Unit>
|
||||
|
||||
@ -131,7 +130,6 @@ class DefaultConversationRepository @Inject constructor(
|
||||
}
|
||||
|
||||
// This assumes that recipient.isContactRecipient is true
|
||||
@Contract
|
||||
override fun setBlocked(recipient: Recipient, blocked: Boolean) {
|
||||
storage.setBlocked(listOf(recipient), blocked)
|
||||
}
|
||||
@ -267,10 +265,14 @@ class DefaultConversationRepository @Inject constructor(
|
||||
return ResultOf.Success(Unit)
|
||||
}
|
||||
|
||||
override suspend fun clearAllMessageRequests(): ResultOf<Unit> {
|
||||
override suspend fun clearAllMessageRequests(block: Boolean): ResultOf<Unit> {
|
||||
threadDb.readerFor(threadDb.unapprovedConversationList).use { reader ->
|
||||
while (reader.next != null) {
|
||||
deleteMessageRequest(reader.current)
|
||||
val recipient = reader.current.recipient
|
||||
if (block && !recipient.isOpenGroupInboxRecipient) {
|
||||
setBlocked(recipient, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
return ResultOf.Success(Unit)
|
||||
|
Loading…
Reference in New Issue
Block a user