Add better ux when group limit reached when joining via link.

This commit is contained in:
Cody Henthorne
2025-12-17 13:49:32 -05:00
committed by jeffrey-signal
parent eb4540600e
commit b7d671dcbd
4 changed files with 17 additions and 2 deletions

View File

@@ -183,6 +183,7 @@ public final class GroupJoinBottomSheetDialogFragment extends BottomSheetDialogF
case GROUP_LINK_NOT_ACTIVE: return getString(R.string.GroupJoinBottomSheetDialogFragment_this_group_link_is_not_active);
case BANNED : return getString(R.string.GroupJoinBottomSheetDialogFragment_you_cant_join_this_group_via_the_group_link_because_an_admin_removed_you);
case NETWORK_ERROR : return getString(R.string.GroupJoinBottomSheetDialogFragment_encountered_a_network_error);
case LIMIT_REACHED : return getString(R.string.GroupJoinBottomSheetDialogFragment_group_limit_reached);
default : return getString(R.string.GroupJoinBottomSheetDialogFragment_unable_to_join_group_please_try_again_later);
}
}

View File

@@ -18,6 +18,7 @@ import org.thoughtcrime.securesms.groups.v2.GroupInviteLinkUrl;
import org.thoughtcrime.securesms.jobs.AvatarGroupsV2DownloadJob;
import org.thoughtcrime.securesms.util.AsynchronousCallback;
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
import org.whispersystems.signalservice.internal.push.exceptions.GroupPatchNotAcceptedException;
import java.io.IOException;
@@ -68,9 +69,19 @@ final class GroupJoinRepository {
} catch (GroupLinkNotActiveException e) {
Log.w(TAG, "Inactive group error", e);
callback.onError(e.getReason() == GroupLinkNotActiveException.Reason.BANNED ? JoinGroupError.BANNED : JoinGroupError.GROUP_LINK_NOT_ACTIVE);
} catch (GroupChangeFailedException | MembershipNotSuitableForV2Exception e) {
Log.w(TAG, "Change failed", e);
} catch (MembershipNotSuitableForV2Exception e) {
Log.w(TAG, "Membership not suitable", e);
callback.onError(JoinGroupError.FAILED);
} catch (GroupChangeFailedException e) {
Log.w(TAG, "Group change failed", e);
JoinGroupError error = JoinGroupError.FAILED;
if (e.getCause() instanceof GroupPatchNotAcceptedException) {
String message = e.getCause().getMessage();
if (message != null && message.contains("group size cannot exceed")) {
error = JoinGroupError.LIMIT_REACHED;
}
}
callback.onError(error);
}
});
}

View File

@@ -5,5 +5,6 @@ enum JoinGroupError {
GROUP_LINK_NOT_ACTIVE,
BANNED,
FAILED,
LIMIT_REACHED,
NETWORK_ERROR,
}