fix(app): add copy link to link channel context menus (#2959)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-25 18:16:20 +02:00
1 parent 5ab8d745c0
commit f1f8ba2031
36 files changed
+585 -544

No files matched your search

@@ -9,6 +9,8 @@ import type {Guild} from '@app/features/guild/models/Guild';
import {
CHANGE_NICKNAME_DESCRIPTOR,
CHANNEL_REMOVED_FROM_FAVORITES_DESCRIPTOR,
COPY_LINK_DESCRIPTOR,
LINK_COPIED_TO_CLIPBOARD_DESCRIPTOR,
OPEN_LINK_DESCRIPTOR,
REMOVE_FROM_FAVORITES_DESCRIPTOR,
UNCATEGORIZED_DESCRIPTOR,
@@ -19,6 +21,7 @@ import * as NavigationCommands from '@app/features/navigation/commands/Navigatio
import Permission from '@app/features/permissions/state/Permission';
import {
ChangeNicknameIcon,
CopyLinkIcon,
DeleteIcon,
OpenInCommunityIcon,
RemoveFromFavoritesIcon,
@@ -38,6 +41,7 @@ import {MenuItem} from '@app/features/ui/action_menu/MenuItem';
import {MenuItemSubmenu} from '@app/features/ui/action_menu/MenuItemSubmenu';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
import {modal} from '@app/features/ui/commands/ModalCommands';
import * as TextCopyCommands from '@app/features/ui/commands/TextCopyCommands';
import * as ToastCommands from '@app/features/ui/commands/ToastCommands';
import UserSettings from '@app/features/user/state/UserSettings';
import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants';
@@ -103,6 +107,12 @@ export const FavoritesChannelContextMenu: React.FC<FavoritesChannelContextMenuPr
onClose();
focusChannelTextareaAfterNavigation(channel.id);
};
const handleCopyLinkChannelUrl = async () => {
if (!channel?.url) return;
await TextCopyCommands.copy(i18n, channel.url, true);
ToastCommands.createToast({type: 'success', children: i18n._(LINK_COPIED_TO_CLIPBOARD_DESCRIPTOR)});
onClose();
};
const handleDeleteMyMessages = () => {
if (!channel) return;
onClose();
@@ -168,6 +178,15 @@ export const FavoritesChannelContextMenu: React.FC<FavoritesChannelContextMenuPr
: i18n._(OPEN_IN_COMMUNITY_DESCRIPTOR)}
</MenuItem>
)}
{channel.type === ChannelTypes.GUILD_LINK && channel.url && (
<MenuItem
icon={<CopyLinkIcon data-flx="ui.action-menu.favorites-channel-context-menu.copy-link-icon" />}
onClick={handleCopyLinkChannelUrl}
data-flx="ui.action-menu.favorites-channel-context-menu.menu-item.copy-link"
>
{i18n._(COPY_LINK_DESCRIPTOR)}
</MenuItem>
)}
{(favoriteChannel.parentId !== null ||
Favorites.sortedCategories.some((category) => category.id !== favoriteChannel.parentId)) && (
<MenuItemSubmenu
@@ -38,10 +38,12 @@ import {
CHANNEL_DEBUG_DESCRIPTOR,
CHANNEL_DELETED_DESCRIPTOR,
COPY_CHANNEL_ID_DESCRIPTOR,
COPY_LINK_DESCRIPTOR,
DEBUG_CHANNEL_DESCRIPTOR,
EDIT_GROUP_DESCRIPTOR,
INVITE_PEOPLE_DESCRIPTOR,
INVITES_DESCRIPTOR,
LINK_COPIED_TO_CLIPBOARD_DESCRIPTOR,
MARK_AS_READ_DESCRIPTOR,
NOTIFICATION_SETTINGS_DESCRIPTOR,
OPEN_LINK_DESCRIPTOR,
@@ -171,6 +173,7 @@ export interface ChannelMenuHandlers {
handleInviteMembers: () => void;
handleCopyChannelLink: () => Promise<void>;
handleOpenChannelLink: () => void;
handleCopyLinkChannelUrl: () => Promise<void>;
handleOpenChat: () => void;
handleOpenMuteSheet: () => void;
handleNotificationSettings: () => void;
@@ -313,6 +316,15 @@ export function useChannelMenuData(
LinkChannelCommands.openLinkChannel(channel);
onClose();
},
handleCopyLinkChannelUrl: async () => {
if (!channel.url) return;
await TextCopyCommands.copy(i18n, channel.url, true);
ToastCommands.createToast({
type: 'success',
children: i18n._(LINK_COPIED_TO_CLIPBOARD_DESCRIPTOR),
});
onClose();
},
handleOpenChat: () => {
if (channel.guildId) {
CompactVoiceCallHeight.setExpandedForKey(getGuildVoiceCallExpansionKey(channel.id), false);
@@ -669,6 +681,16 @@ export function useChannelMenuData(
label: i18n._(OPEN_LINK_DESCRIPTOR),
onClick: handlers.handleOpenChannelLink,
});
inviteItems.push({
icon: (
<CopyLinkIcon
size={20}
data-flx="ui.action-menu.items.channel-menu-data.groups.copy-link-channel-url-icon"
/>
),
label: i18n._(COPY_LINK_DESCRIPTOR),
onClick: handlers.handleCopyLinkChannelUrl,
});
}
inviteItems.push({
icon: <CopyLinkIcon size={20} data-flx="ui.action-menu.items.channel-menu-data.groups.copy-link-icon" />,