Forward Recipient Picker: Fix recipient list by excluding channel chats when forwarding (#5964)
This commit is contained in:
parent
546943b478
commit
0ac8aae0eb
@ -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)!;
|
||||||
|
|
||||||
|
|||||||
@ -118,6 +118,7 @@ const ForwardRecipientPicker: FC<OwnProps & StateProps> = ({
|
|||||||
onSelectRecipient={handleSelectRecipient}
|
onSelectRecipient={handleSelectRecipient}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
onCloseAnimationEnd={unmarkIsShown}
|
onCloseAnimationEnd={unmarkIsShown}
|
||||||
|
isForwarding={isForwarding}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user