fix(api): let channel managers edit a mature channel (#2583)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-08 14:51:47 +02:00
1 parent 2019909a5e
commit a2a68847fd
6 files changed
+44 -35

No files matched your search

@@ -17,7 +17,6 @@ import {
UNPIN_GROUP_DM_DESCRIPTOR,
} from '@app/features/channel/utils/ChannelMessageDescriptors';
import {isGroupDmFull} from '@app/features/channel/utils/GroupDmUtils';
import Guilds from '@app/features/guild/state/Guilds';
import {
ADD_TO_FAVORITES_DESCRIPTOR,
COPY_CHANNEL_ID_DESCRIPTOR,
@@ -32,7 +31,6 @@ import {
REMOVE_FROM_FAVORITES_DESCRIPTOR,
} from '@app/features/i18n/utils/CommonMessageDescriptors';
import * as InviteUtils from '@app/features/invite/utils/InviteUtils';
import {getEffectiveChannelMatureContent} from '@app/features/messaging/utils/ContentWarningUtils';
import Permission from '@app/features/permissions/state/Permission';
import ReadStates from '@app/features/read_state/state/ReadStates';
import {AddFriendsToGroupModal} from '@app/features/relationship/components/modals/AddFriendsToGroupModal';
@@ -56,7 +54,6 @@ import {modal} from '@app/features/ui/commands/ModalCommands';
import type {MenuGroupType, MenuItemType} from '@app/features/ui/menu_bottom_sheet/MenuBottomSheet';
import {MenuBottomSheet} from '@app/features/ui/menu_bottom_sheet/MenuBottomSheet';
import type {User} from '@app/features/user/models/User';
import Users from '@app/features/user/state/Users';
import {Permissions} from '@fluxer/constants/src/ChannelConstants';
import {useLingui} from '@lingui/react/macro';
import type React from 'react';
@@ -251,21 +248,14 @@ export const MoreOptionsSheet: React.FC<MoreOptionsSheetProps> = ({
guildId: channel.guildId,
});
if (canManageChannels) {
const guildForChannel = channel.guildId ? Guilds.getGuild(channel.guildId) : undefined;
const currentUser = Users.getCurrentUser();
const nsfwBlockedForMinor =
getEffectiveChannelMatureContent(channel, guildForChannel ?? null) &&
!!currentUser &&
!currentUser.matureContentAllowed;
const managerItems: Array<MenuItemType> = [];
if (!nsfwBlockedForMinor) {
managerItems.push({
const managerItems: Array<MenuItemType> = [
{
id: 'edit-channel',
icon: <EditIcon size={20} data-flx="channel.channel-details-bottom-sheet.edit-icon--2" />,
label: i18n._(EDIT_CHANNEL_DESCRIPTOR),
onClick: onEditChannel,
});
}
},
];
managerItems.push({
id: 'delete-channel',
icon: <DeleteIcon size={20} data-flx="channel.channel-details-bottom-sheet.delete-icon" />,
@@ -54,7 +54,6 @@ import {
import {InviteModal} from '@app/features/invite/components/modals/InviteModal';
import * as InviteUtils from '@app/features/invite/utils/InviteUtils';
import Favorites from '@app/features/messaging/state/Favorites';
import {getEffectiveChannelMatureContent} from '@app/features/messaging/utils/ContentWarningUtils';
import {buildChannelLink} from '@app/features/messaging/utils/MessageLinkUtils';
import * as NavigationCommands from '@app/features/navigation/commands/NavigationCommands';
import Permission from '@app/features/permissions/state/Permission';
@@ -88,7 +87,6 @@ import * as ToastCommands from '@app/features/ui/commands/ToastCommands';
import type {MenuActionEvent, MenuGroupType, MenuItemType} from '@app/features/ui/menu_bottom_sheet/MenuBottomSheet';
import UserGuildSettings from '@app/features/user/state/UserGuildSettings';
import UserSettings from '@app/features/user/state/UserSettings';
import Users from '@app/features/user/state/Users';
import CompactVoiceCallHeight, {getGuildVoiceCallExpansionKey} from '@app/features/voice/state/CompactVoiceCallHeight';
import {getMutedText} from '@app/lib/overlay/OverlayContextMenu';
import {ME} from '@fluxer/constants/src/AppConstants';
@@ -203,7 +201,6 @@ export interface ChannelMenuState {
hasUnread: boolean;
canManageChannels: boolean;
canEditChannel: boolean;
nsfwBlockedForMinor: boolean;
canInvite: boolean;
developerMode: boolean;
isPinned: boolean;
@@ -237,10 +234,6 @@ function getChannelMenuState(channel: Channel, guild: Guild | undefined): Channe
guildId: channel.guildId,
});
const canEditChannel = canManageChannels || canUpdateRtcRegion;
const currentUser = Users.getCurrentUser();
const channelIsNsfw =
(isTextChannel || isVoiceChannel || isLinkChannel) && getEffectiveChannelMatureContent(channel, guild ?? null);
const nsfwBlockedForMinor = channelIsNsfw && !!currentUser && !currentUser.matureContentAllowed;
const canInvite = InviteUtils.canInviteToChannel(channel.id, channel.guildId);
const developerMode = UserSettings.developerMode;
const isPinned = channel.isPinned;
@@ -256,7 +249,6 @@ function getChannelMenuState(channel: Channel, guild: Guild | undefined): Channe
hasUnread,
canManageChannels,
canEditChannel,
nsfwBlockedForMinor,
canInvite,
developerMode,
isPinned,
@@ -711,24 +703,21 @@ export function useChannelMenuData(
});
menuGroups.push({items: notificationItems});
if (state.canEditChannel) {
const manageItems: Array<MenuItemType> = [];
if (!state.nsfwBlockedForMinor) {
manageItems.push({
const manageItems: Array<MenuItemType> = [
{
icon: <SettingsIcon size={20} data-flx="ui.action-menu.items.channel-menu-data.groups.settings-icon" />,
label: i18n._(EDIT_CHANNEL_DESCRIPTOR),
onClick: handlers.handleChannelSettings,
});
}
if (state.canManageChannels && !state.nsfwBlockedForMinor) {
},
];
if (state.canManageChannels) {
manageItems.push({
icon: <CopyIcon size={20} data-flx="ui.action-menu.items.channel-menu-data.groups.copy-icon" />,
label: i18n._(DUPLICATE_CHANNEL_DESCRIPTOR),
onClick: handlers.handleDuplicateChannel,
});
}
if (manageItems.length > 0) {
menuGroups.push({items: manageItems});
}
menuGroups.push({items: manageItems});
}
const debugItems: Array<MenuItemType> = [];
if (state.developerMode) {