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

View File

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

View File

@ -421,7 +421,7 @@ namespace Api {
export type TypeAccessPointRule = AccessPointRule; export type TypeAccessPointRule = AccessPointRule;
export type TypeTlsClientHello = TlsClientHello; export type TypeTlsClientHello = TlsClientHello;
export type TypeTlsBlock = TlsBlockString | TlsBlockRandom | TlsBlockZero | TlsBlockDomain | TlsBlockGrease | TlsBlockScope; export type TypeTlsBlock = TlsBlockString | TlsBlockRandom | TlsBlockZero | TlsBlockDomain | TlsBlockGrease | TlsBlockScope;
export namespace storage { 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; 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; static fromReader(reader: Reader): TlsBlockScope;
} }
export namespace storage { export namespace storage {
export class FileUnknown extends VirtualClass<void> { export class FileUnknown extends VirtualClass<void> {
@ -22139,7 +22139,7 @@ namespace Api {
}>, Api.TypeDestroySessionRes> { }>, Api.TypeDestroySessionRes> {
sessionId: long; sessionId: long;
} }
export namespace auth { export namespace auth {
export class SendCode extends Request<Partial<{ export class SendCode extends Request<Partial<{