Forward Recipient Picker: Fix recipient list by excluding channel chats when forwarding (#5964)

This commit is contained in:
Alexander Zinchuk 2025-07-04 14:12:13 +02:00
parent 546943b478
commit 0ac8aae0eb
3 changed files with 22 additions and 4 deletions

View File

@ -8,6 +8,8 @@ import type { ThreadId } from '../../types';
import { API_CHAT_TYPES } from '../../config';
import {
getCanPostInChat,
getHasAdminRight,
isChatChannel,
isDeletedUser,
} from '../../global/helpers';
import { filterPeersByQuery } from '../../global/helpers/peers';
@ -31,6 +33,7 @@ export type OwnProps = {
onClose: NoneToVoidFunction;
onCloseAnimationEnd?: NoneToVoidFunction;
isLowStackPriority?: boolean;
isForwarding?: boolean;
};
type StateProps = {
@ -56,6 +59,7 @@ const RecipientPicker: FC<OwnProps & StateProps> = ({
onClose,
onCloseAnimationEnd,
isLowStackPriority,
isForwarding,
}) => {
const [search, setSearch] = useState('');
const ids = useMemo(() => {
@ -75,6 +79,9 @@ const RecipientPicker: FC<OwnProps & StateProps> = ({
].filter((id) => {
const chat = selectChat(global, id);
const user = selectUser(global, id);
const hasAdminRights = chat && getHasAdminRight(chat, 'postMessages');
const isChannel = chat && isChatChannel(chat);
if (isForwarding && isChannel && !hasAdminRights) return false;
if (user && !isDeletedUser(user)) return true;
if (!chat) return false;
@ -103,7 +110,17 @@ const RecipientPicker: FC<OwnProps & StateProps> = ({
);
return filterChatIdsByType(global, sorted, filter);
}, [pinnedIds, currentUserId, activeListIds, search, archivedListIds, contactIds, filter, isOpen]);
}, [
isOpen,
pinnedIds,
currentUserId,
activeListIds,
search,
archivedListIds,
contactIds,
filter,
isForwarding,
]);
const renderingIds = useCurrentOrPrev(ids, true)!;

View File

@ -118,6 +118,7 @@ const ForwardRecipientPicker: FC<OwnProps & StateProps> = ({
onSelectRecipient={handleSelectRecipient}
onClose={handleClose}
onCloseAnimationEnd={unmarkIsShown}
isForwarding={isForwarding}
/>
);
};

View File

@ -421,7 +421,7 @@ namespace Api {
export type TypeAccessPointRule = AccessPointRule;
export type TypeTlsClientHello = TlsClientHello;
export type TypeTlsBlock = TlsBlockString | TlsBlockRandom | TlsBlockZero | TlsBlockDomain | TlsBlockGrease | TlsBlockScope;
export namespace storage {
export type TypeFileType = storage.FileUnknown | storage.FilePartial | storage.FileJpeg | storage.FileGif | storage.FilePng | storage.FilePdf | storage.FileMp3 | storage.FileMov | storage.FileMp4 | storage.FileWebp;
@ -17810,7 +17810,7 @@ namespace Api {
static fromReader(reader: Reader): TlsBlockScope;
}
export namespace storage {
export class FileUnknown extends VirtualClass<void> {
@ -22139,7 +22139,7 @@ namespace Api {
}>, Api.TypeDestroySessionRes> {
sessionId: long;
}
export namespace auth {
export class SendCode extends Request<Partial<{