diff --git a/src/components/main/AppendEntityPicker.module.scss b/src/components/main/AppendEntityPicker.module.scss index 5c43b6c6a..8ae2b3467 100644 --- a/src/components/main/AppendEntityPicker.module.scss +++ b/src/components/main/AppendEntityPicker.module.scss @@ -42,5 +42,5 @@ } .picker { - height: 70vh; + height: 75vh; } diff --git a/src/components/main/AppendEntityPickerModal.tsx b/src/components/main/AppendEntityPickerModal.tsx index f5874cfef..b01e9e733 100644 --- a/src/components/main/AppendEntityPickerModal.tsx +++ b/src/components/main/AppendEntityPickerModal.tsx @@ -1,8 +1,6 @@ import type { FC } from '../../lib/teact/teact'; import React, { - memo, - useMemo, - useState, + memo, useMemo, useState, } from '../../lib/teact/teact'; import { getActions, getGlobal, withGlobal } from '../../global'; @@ -10,7 +8,7 @@ import type { ApiChat, ApiChatMember, ApiUserStatus } from '../../api/types'; import { filterChatsByName, - filterUsersByName, isChatChannel, isChatPublic, isUserBot, sortUserIds, + filterUsersByName, isChatChannel, isChatPublic, isChatSuperGroup, isUserBot, sortUserIds, } from '../../global/helpers'; import { selectChat, selectChatFullInfo } from '../../global/selectors'; import buildClassName from '../../util/buildClassName'; @@ -45,6 +43,7 @@ interface StateProps { userStatusesById: Record; channelList?: (ApiChat | undefined)[] | undefined; isChannel?: boolean; + isSuperGroup?: boolean; currentUserId?: string | undefined; } @@ -57,6 +56,7 @@ const AppendEntityPickerModal: FC = ({ userStatusesById, entityType, isChannel, + isSuperGroup, onSubmit, currentUserId, selectionLimit, @@ -76,7 +76,8 @@ const AppendEntityPickerModal: FC = ({ const activeChatIds = getGlobal().chats.listIds.active; return activeChatIds!.map((id) => chatsById[id]) - .filter((chat) => chat && isChatChannel(chat) && chat.id !== chatId) + .filter((chat) => chat && (isChatChannel(chat) + || isChatSuperGroup(chat)) && chat.id !== chatId) .map((chat) => chat!.id); }, [chatId]); @@ -123,11 +124,11 @@ const AppendEntityPickerModal: FC = ({ return true; } - return isChannel; + return isChannel || isSuperGroup; }), false, selectedChannelIds); - }, [channelsIds, lang, searchQuery, selectedChannelIds, isChannel]); + }, [channelsIds, lang, searchQuery, selectedChannelIds, isSuperGroup, isChannel]); const handleCloseButtonClick = useLastCallback(() => { onSubmit([]); @@ -248,6 +249,7 @@ const AppendEntityPickerModal: FC = ({ export default memo(withGlobal((global, { chatId, entityType }): StateProps => { const { statusesById: userStatusesById } = global.users; let isChannel; + let isSuperGroup; let members: ApiChatMember[] | undefined; let adminMembersById: Record | undefined; let currentUserId: string | undefined; @@ -263,6 +265,7 @@ export default memo(withGlobal((global, { chatId, entityType }): State const chat = chatId ? selectChat(global, chatId) : undefined; if (chat) { isChannel = isChatChannel(chat); + isSuperGroup = isChatSuperGroup(chat); } } @@ -272,6 +275,7 @@ export default memo(withGlobal((global, { chatId, entityType }): State adminMembersById, userStatusesById, isChannel, + isSuperGroup, currentUserId, }; })(AppendEntityPickerModal)); diff --git a/src/components/main/premium/GiveawayModal.tsx b/src/components/main/premium/GiveawayModal.tsx index 52868eddc..ca74cd30a 100644 --- a/src/components/main/premium/GiveawayModal.tsx +++ b/src/components/main/premium/GiveawayModal.tsx @@ -15,8 +15,9 @@ import { GIVEAWAY_MAX_ADDITIONAL_COUNTRIES, GIVEAWAY_MAX_ADDITIONAL_USERS, } from '../../../config'; -import { getUserFullName } from '../../../global/helpers'; +import { getUserFullName, isChatChannel } from '../../../global/helpers'; import { + selectChat, selectTabState, } from '../../../global/selectors'; import buildClassName from '../../../util/buildClassName'; @@ -69,6 +70,7 @@ type StateProps = { countryList: ApiCountry[]; prepaidGiveaway?: ApiPrepaidGiveaway; countrySelectionLimit: number | undefined; + isChannel?: boolean; }; type GiveawayAction = 'createRandomlyUsers' | 'createSpecificUsers'; @@ -99,6 +101,7 @@ const GiveawayModal: FC = ({ chatId, gifts, isOpen, + isChannel, selectedMemberList, selectedChannelList, giveawayBoostPerPremiumLimit = GIVEAWAY_BOOST_PER_PREMIUM, @@ -160,19 +163,19 @@ const GiveawayModal: FC = ({ const SUBSCRIBER_OPTIONS = useMemo(() => [ { value: 'all', - label: lang('BoostingAllSubscribers'), + label: lang(isChannel ? 'BoostingAllSubscribers' : 'BoostingAllMembers'), subLabel: selectedCountriesIds && selectedCountriesIds.length > 0 ? lang('Giveaway.ReceiverType.Countries', selectedCountriesIds.length) : lang('BoostingFromAllCountries'), }, { value: 'new', - label: lang('BoostingNewSubscribers'), + label: lang(isChannel ? 'BoostingNewSubscribers' : 'BoostingNewMembers'), subLabel: selectedCountriesIds && selectedCountriesIds.length > 0 ? lang('Giveaway.ReceiverType.Countries', selectedCountriesIds.length) : lang('BoostingFromAllCountries'), }, - ], [lang, selectedCountriesIds]); + ], [isChannel, lang, selectedCountriesIds]); const monthQuantity = lang('Months', selectedMonthOption); @@ -448,7 +451,7 @@ const GiveawayModal: FC = ({ {renderText(lang('BoostingBoostsViaGifts'))}
- {renderText(lang('BoostingGetMoreBoost'))} + {renderText(lang(isChannel ? 'BoostingGetMoreBoost' : 'BoostingGetMoreBoostsGroup'))}

@@ -522,7 +525,8 @@ const GiveawayModal: FC = ({ > @@ -551,7 +555,7 @@ const GiveawayModal: FC = ({ className={styles.addButton} iconClassName={styles.addChannel} > - {lang('BoostingAddChannel')} + {lang('BoostingAddChannelOrGroup')} )}

@@ -565,7 +569,7 @@ const GiveawayModal: FC = ({
- {renderText(lang('BoostGift.LimitSubscribersInfo'))} + {renderText(lang(isChannel ? 'BoostGift.LimitSubscribersInfo' : 'lng_giveaway_users_about_group'))}
@@ -726,9 +730,12 @@ export default memo(withGlobal((global): StateProps => { const { giveawayModal, } = selectTabState(global); + const chatId = giveawayModal?.chatId; + const chat = chatId ? selectChat(global, chatId) : undefined; + const isChannel = chat && isChatChannel(chat); return { - chatId: giveawayModal?.chatId, + chatId, gifts: giveawayModal?.gifts, selectedMemberList: giveawayModal?.selectedMemberIds, selectedChannelList: giveawayModal?.selectedChannelIds, @@ -737,5 +744,6 @@ export default memo(withGlobal((global): StateProps => { countrySelectionLimit: global.appConfig?.giveawayCountriesMax, countryList: global.countryList.general, prepaidGiveaway: giveawayModal?.prepaidGiveaway, + isChannel, }; })(GiveawayModal)); diff --git a/src/components/middle/HeaderActions.tsx b/src/components/middle/HeaderActions.tsx index ada229dbb..a8f7b9421 100644 --- a/src/components/middle/HeaderActions.tsx +++ b/src/components/middle/HeaderActions.tsx @@ -500,7 +500,8 @@ export default memo(withGlobal( const canCreateVoiceChat = ARE_CALLS_SUPPORTED && isMainThread && !chat.isCallActive && (chat.adminRights?.manageCall || (chat.isCreator && isChatBasicGroup(chat))); const canViewStatistics = isMainThread && chatFullInfo?.canViewStatistics; - const canViewBoosts = isMainThread && isChannel && (canViewStatistics || getHasAdminRight(chat, 'postStories')); + const canViewBoosts = isMainThread + && (isSuperGroup || isChannel) && (canViewStatistics || getHasAdminRight(chat, 'postStories')); const canShowBoostModal = !canViewBoosts && (isSuperGroup || isChannel); const pendingJoinRequests = isMainThread ? chatFullInfo?.requestsPending : undefined; const shouldJoinToSend = Boolean(chat?.isNotJoined && chat.isJoinToSend); diff --git a/src/components/right/statistics/BoostStatistics.tsx b/src/components/right/statistics/BoostStatistics.tsx index 0cfee49bf..6ff1b4373 100644 --- a/src/components/right/statistics/BoostStatistics.tsx +++ b/src/components/right/statistics/BoostStatistics.tsx @@ -5,7 +5,8 @@ import type { ApiBoostStatistics, ApiPrepaidGiveaway } from '../../../api/types' import type { TabState } from '../../../global/types'; import { GIVEAWAY_BOOST_PER_PREMIUM } from '../../../config'; -import { selectIsGiveawayGiftsPurchaseAvailable, selectTabState } from '../../../global/selectors'; +import { isChatChannel } from '../../../global/helpers'; +import { selectChat, selectIsGiveawayGiftsPurchaseAvailable, selectTabState } from '../../../global/selectors'; import buildClassName from '../../../util/buildClassName'; import { formatDateAtTime } from '../../../util/date/dateFormat'; import { getBoostProgressInfo } from '../../common/helpers/boostInfo'; @@ -33,6 +34,7 @@ type StateProps = { isGiveawayAvailable?: boolean; chatId: string; giveawayBoostsPerPremium?: number; + isChannel?: boolean; }; const GIVEAWAY_IMG_LIST: { [key: number]: string } = { @@ -46,6 +48,7 @@ const BoostStatistics = ({ isGiveawayAvailable, chatId, giveawayBoostsPerPremium, + isChannel, }: StateProps) => { const { openChat, loadMoreBoosters, closeBoostStatistics, openGiveawayModal, @@ -162,51 +165,56 @@ const BoostStatistics = ({

{lang('BoostingSelectPaidGiveaway')}

)} -
-

- {lang('Boosters')} -

- {!boostStatistics.boosterIds?.length && ( -
{lang('NoBoostersHint')}
- )} - {boostStatistics.boosterIds?.map((userId) => ( - handleBoosterClick(userId)} - > - - - ))} - {Boolean(boostersToLoadCount) && ( - - {boostStatistics?.isLoadingBoosters ? ( - - ) : ( - - )} - {lang('ShowVotes', boostersToLoadCount)} - - )} -
+ {isChannel && ( +
+

+ {lang('Boosters')} +

+ {!boostStatistics.boosterIds?.length && ( +
{lang('NoBoostersHint')}
+ )} + {boostStatistics.boosterIds?.map((userId) => ( + handleBoosterClick(userId)} + > + + + ))} + {Boolean(boostersToLoadCount) && ( + + {boostStatistics?.isLoadingBoosters ? ( + + ) : ( + + )} + {lang('ShowVotes', boostersToLoadCount)} + + )} +
+ )} {isGiveawayAvailable && (
{lang('BoostingGetBoostsViaGifts')} -

{lang('BoostingGetMoreBoosts')}

+

{lang( + isChannel ? 'BoostingGetMoreBoosts' : 'BoostingGetMoreBoostsGroup', + )} +

)} @@ -221,6 +229,8 @@ export default memo(withGlobal( const boostStatistics = tabState.boostStatistics; const isGiveawayAvailable = selectIsGiveawayGiftsPurchaseAvailable(global); const chatId = boostStatistics && boostStatistics.chatId; + const chat = chatId ? selectChat(global, chatId) : undefined; + const isChannel = chat && isChatChannel(chat); const giveawayBoostsPerPremium = global.appConfig?.giveawayBoostsPerPremium; return { @@ -228,6 +238,7 @@ export default memo(withGlobal( isGiveawayAvailable, chatId: chatId!, giveawayBoostsPerPremium, + isChannel, }; }, )(BoostStatistics));