mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-23 20:48:43 +00:00
Fix crash for leave gv1.
This commit is contained in:
@@ -362,6 +362,8 @@ public class NewConversationActivity extends ContactSelectionActivity
|
||||
handleManualRefresh();
|
||||
displaySnackbar(R.string.NewConversationActivity__s_has_been_blocked, recipient.getDisplayName(this));
|
||||
contactsFragment.reset();
|
||||
}, (throwable) -> {
|
||||
displaySnackbar(R.string.NewConversationActivity__block_failed);
|
||||
}));
|
||||
})
|
||||
);
|
||||
|
||||
@@ -171,14 +171,19 @@ class ConversationSettingsRepository(
|
||||
}
|
||||
}
|
||||
|
||||
fun block(recipientId: RecipientId) {
|
||||
SignalExecutors.BOUNDED.execute {
|
||||
@WorkerThread
|
||||
fun block(recipientId: RecipientId): GroupChangeResult {
|
||||
return try {
|
||||
val recipient = Recipient.resolved(recipientId)
|
||||
if (recipient.isGroup) {
|
||||
RecipientUtil.block(context, recipient)
|
||||
} else {
|
||||
RecipientUtil.blockNonGroup(context, recipient)
|
||||
}
|
||||
GroupChangeResult.SUCCESS
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to block recipient.", e)
|
||||
GroupChangeResult.failure(GroupChangeFailureReason.fromException(e))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,15 @@ sealed class ConversationSettingsViewModel(
|
||||
}
|
||||
|
||||
override fun block() {
|
||||
repository.block(recipientId)
|
||||
viewModelScope.launch {
|
||||
val result = withContext(SignalDispatchers.IO) {
|
||||
repository.block(recipientId)
|
||||
}
|
||||
|
||||
if (!result.isSuccess) {
|
||||
internalEvents.onNext(ConversationSettingsEvent.ShowBlockGroupError(result.getFailureReason()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unblock() {
|
||||
|
||||
@@ -80,7 +80,8 @@ public final class GroupManager {
|
||||
throws GroupChangeBusyException, GroupChangeFailedException, IOException
|
||||
{
|
||||
if (!groupId.isV2()) {
|
||||
throw new GroupChangeFailedException("Not gv2");
|
||||
Log.w(TAG, "Not gv2");
|
||||
return;
|
||||
}
|
||||
|
||||
try (GroupManagerV2.GroupEditor edit = new GroupManagerV2(context).edit(groupId.requireV2())) {
|
||||
@@ -101,7 +102,8 @@ public final class GroupManager {
|
||||
throws IOException, GroupChangeBusyException, GroupChangeFailedException
|
||||
{
|
||||
if (!groupId.isV2()) {
|
||||
throw new GroupChangeFailedException("Not gv2");
|
||||
Log.w(TAG, "Not gv2");
|
||||
return;
|
||||
}
|
||||
|
||||
leaveGroup(context, groupId.requireV2(), true);
|
||||
|
||||
@@ -5843,6 +5843,8 @@
|
||||
<string name="NewConversationActivity__s_has_been_removed">%1$s has been removed</string>
|
||||
<!-- Snackbar message after blocking a contact -->
|
||||
<string name="NewConversationActivity__s_has_been_blocked">%1$s has been blocked</string>
|
||||
<!-- Snackbar message when blocking a contact has failed -->
|
||||
<string name="NewConversationActivity__block_failed">Block failed</string>
|
||||
<!-- Dialog title when remove target contact is in system contacts -->
|
||||
<string name="NewConversationActivity__unable_to_remove_s">Unable to remove %1$s</string>
|
||||
<!-- Dialog message when remove target contact is in system contacts -->
|
||||
|
||||
Reference in New Issue
Block a user