Skip to content

Commit b7c18ac

Browse files
dallo28claude
andcommitted
Fix "Set as Main Tab" option showing for supergroups
Supergroups share TL_channelFull with broadcast channels, so the `info instanceof TL_channelFull` check let group admins set a main profile tab, which the server ignores for groups. Use ChatObject.isChannelAndNotMegaGroup via a single helper instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f2908b1 commit b7c18ac

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

‎TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,11 +4473,12 @@ public boolean canReorder(int page) {
44734473
@Override
44744474
public boolean showOptions(int page, View view) {
44754475
if (profileActivity == null) return false;
4476-
if (getTab(page, info instanceof TLRPC.TL_channelFull) == null) {
4476+
final boolean isChannel = isBroadcastChannelProfile();
4477+
if (getTab(page, isChannel) == null) {
44774478
return false;
44784479
}
44794480
final TLRPC.ProfileTab main_tab;
4480-
if (info instanceof TLRPC.TL_channelFull) {
4481+
if (isChannel) {
44814482
final TLRPC.Chat chat = profileActivity.getMessagesController().getChat(info.id);
44824483
if (!ChatObject.canUserDoAction(chat, ChatObject.ACTION_POST))
44834484
return false;
@@ -4495,7 +4496,7 @@ public boolean showOptions(int page, View view) {
44954496
o.add(R.drawable.tabs_reorder, getString(R.string.ProfileTabSetAsMain), () -> {
44964497
if (profileActivity == null) return;
44974498
final TLObject r;
4498-
if (info instanceof TLRPC.TL_channelFull) {
4499+
if (isChannel) {
44994500
TLRPC.TL_channels_setMainProfileTab req = new TLRPC.TL_channels_setMainProfileTab();
45004501
req.tab = getTab(page, true);
45014502
req.channel = profileActivity.getMessagesController().getInputChannel(info.id);
@@ -7046,7 +7047,7 @@ public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues sta
70467047
}
70477048
return false;
70487049
};
7049-
final boolean isChannel = info instanceof TLRPC.TL_channelFull;
7050+
final boolean isChannel = isBroadcastChannelProfile();
70507051
for (int i = 0; i < 15; ++i) {
70517052
if (getTab(i, isChannel) != null && !has.run(i)) {
70527053
tabs.add(new Pair<>(i, getTabName(i)));
@@ -12538,6 +12539,12 @@ private StoriesController getStoriesController() {
1253812539
.getStoriesController();
1253912540
}
1254012541

12542+
// Supergroups also use TL_channelFull, but only broadcast channels support profile tabs
12543+
private boolean isBroadcastChannelProfile() {
12544+
if (info == null || profileActivity == null) return false;
12545+
return ChatObject.isChannelAndNotMegaGroup(profileActivity.getMessagesController().getChat(info.id));
12546+
}
12547+
1254112548
public static TLRPC.ProfileTab getTab(int id, boolean isChannel) {
1254212549
if (id != TAB_STORIES && id != TAB_GIFTS && !isChannel)
1254312550
return null;
@@ -12583,9 +12590,10 @@ public static int getTabId(TLRPC.ProfileTab tab) {
1258312590
public void sendTabsOrder() {
1258412591
if (profileActivity == null || scrollSlidingTextTabStrip == null) return;
1258512592

12593+
final boolean isChannel = isBroadcastChannelProfile();
1258612594
final ArrayList<TLRPC.ProfileTab> order = new ArrayList<>();
1258712595
for (int id : scrollSlidingTextTabStrip.getTabIds()) {
12588-
final TLRPC.ProfileTab tab = getTab(id, info instanceof TLRPC.TL_channelFull);
12596+
final TLRPC.ProfileTab tab = getTab(id, isChannel);
1258912597
if (tab != null) {
1259012598
order.add(tab);
1259112599
}

0 commit comments

Comments
 (0)