diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 1bafd820f..7e84c6424 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -1444,10 +1444,11 @@ export async function addChatMembers(chat: ApiChat, users: ApiUser[]) { shouldIgnoreUpdates: true, shouldThrow: true, }); - if (updates) { - processUpdate(updates); - return handleUserPrivacyRestrictedUpdates(updates); + if (!updates) { + return undefined; } + processUpdate(updates); + return handleUserPrivacyRestrictedUpdates(updates); } catch (err) { if ((err as Error).message === 'USER_PRIVACY_RESTRICTED') { return users.map(({ id }) => id); diff --git a/src/components/common/Picker.tsx b/src/components/common/Picker.tsx index dbca0f491..dfaecaaef 100644 --- a/src/components/common/Picker.tsx +++ b/src/components/common/Picker.tsx @@ -37,6 +37,7 @@ type OwnProps = { isRoundCheckbox?: boolean; lockedIds?: string[]; forceShowSelf?: boolean; + isViewOnly?: boolean; onSelectedIdsChange?: (ids: string[]) => void; onFilterChange?: (value: string) => void; onDisabledClick?: (id: string) => void; @@ -63,6 +64,7 @@ const Picker: FC = ({ isRoundCheckbox, lockedIds, forceShowSelf, + isViewOnly, onSelectedIdsChange, onFilterChange, onDisabledClick, @@ -171,7 +173,7 @@ const Picker: FC = ({ > {viewportIds.map((id) => { const renderCheckbox = () => { - return ( + return isViewOnly ? undefined : ( = ({ key={id} className={buildClassName('chat-item-clickable picker-list-item', isRoundCheckbox && 'chat-item')} disabled={lockedIdsSet.has(id)} + inactive={isViewOnly} allowDisabledClick={Boolean(onDisabledClick)} // eslint-disable-next-line react/jsx-no-bind onClick={() => handleItemClick(id)} diff --git a/src/components/main/InviteViaLinkModal.tsx b/src/components/main/InviteViaLinkModal.tsx index 19f987877..4be9003e0 100644 --- a/src/components/main/InviteViaLinkModal.tsx +++ b/src/components/main/InviteViaLinkModal.tsx @@ -7,6 +7,7 @@ import React, { import { getActions, getGlobal } from '../../global'; import { getUserFullName } from '../../global/helpers'; +import { selectChat } from '../../global/selectors'; import renderText from '../common/helpers/renderText'; import useLang from '../../hooks/useLang'; @@ -50,39 +51,68 @@ const InviteViaLinkModal: FC = ({ return userIds?.map((userId) => getUserFullName(usersById[userId])).join(', '); }, [userIds]); + const canSendInviteLink = useMemo(() => { + if (!chatId) { + return false; + } + const chat = selectChat(getGlobal(), chatId); + return Boolean(chat?.isCreator || chat?.adminRights?.inviteUsers); + }, [chatId]); + + const contentText = useMemo(() => { + const langKey = canSendInviteLink + ? 'SendInviteLink.TextAvailableSingleUser' + : 'SendInviteLink.TextUnavailableSingleUser'; + return renderText(lang(langKey, userNames), ['simple_markdown']); + }, [userNames, lang, canSendInviteLink]); + return (

- {renderText(lang('SendInviteLink.TextAvailableSingleUser', userNames), ['simple_markdown'])} + {contentText}

- - + {canSendInviteLink && ( + + )} + {canSendInviteLink && ( + + )} + {!canSendInviteLink && ( + + )}
);