mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Don't show premium star when premium unavailable.
This commit is contained in:
parent
aaf1383304
commit
916f86b401
Telegram
Resources/icons
SourceFiles
Binary file not shown.
Before ![]() (image error) Size: 282 B |
Binary file not shown.
Before ![]() (image error) Size: 524 B |
Binary file not shown.
Before ![]() (image error) Size: 718 B |
@ -1941,7 +1941,7 @@ auto ParticipantsBoxController::computeType(
|
||||
? Badge::Fake
|
||||
: user->isVerified()
|
||||
? Badge::Verified
|
||||
: user->isPremium()
|
||||
: (user->isPremium() && participant->session().premiumPossible())
|
||||
? Badge::Premium
|
||||
: Badge::None;
|
||||
return result;
|
||||
|
@ -472,29 +472,6 @@ infoChannelsAddChannel: IconButton(infoMembersButton) {
|
||||
iconOver: icon {{ "settings/settings_edit_name", menuIconFgOver, point(9px, 9px) }};
|
||||
}
|
||||
|
||||
infoMembersCreatorIcon: icon {{
|
||||
"profile_admin_star",
|
||||
profileAdminStartFg,
|
||||
point(4px, 3px)
|
||||
}};
|
||||
infoMembersCreatorIconOver: icon {{
|
||||
"profile_admin_star",
|
||||
profileAdminStarFgOver,
|
||||
point(4px, 3px)
|
||||
}};
|
||||
infoMembersAdminIcon: icon {{
|
||||
"profile_admin_star",
|
||||
profileOtherAdminStarFg,
|
||||
point(4px, 3px)
|
||||
}};
|
||||
infoMembersAdminIconOver: icon {{
|
||||
"profile_admin_star",
|
||||
profileOtherAdminStarFgOver,
|
||||
point(4px, 3px)
|
||||
}};
|
||||
infoMembersAdminIconMarigns: margins(10px, 18px, 10px, 10px);
|
||||
infoMembersRemoveIconMargins: margins(10px, 12px, 12px, 10px);
|
||||
|
||||
infoMediaHeaderStyle: TextStyle(semiboldTextStyle) {
|
||||
}
|
||||
infoMediaHeaderHeight: 28px;
|
||||
|
@ -271,6 +271,9 @@ void Cover::initViewers(rpl::producer<QString> title) {
|
||||
BadgeValue(
|
||||
_peer
|
||||
) | rpl::start_with_next([=](Badge badge) {
|
||||
if (badge == Badge::Premium && !_peer->session().premiumPossible()) {
|
||||
badge = Badge::None;
|
||||
}
|
||||
setBadge(badge);
|
||||
}, lifetime());
|
||||
}
|
||||
|
@ -133,6 +133,13 @@ Session::Session(
|
||||
}
|
||||
}, _lifetime);
|
||||
|
||||
_account->appConfig().value(
|
||||
) | rpl::start_with_next([=] {
|
||||
_premiumPossible = !_account->appConfig().get<bool>(
|
||||
"premium_purchase_blocked",
|
||||
true);
|
||||
}, _lifetime);
|
||||
|
||||
if (_settings->hadLegacyCallsPeerToPeerNobody()) {
|
||||
api().userPrivacy().save(
|
||||
Api::UserPrivacy::Key::CallsPeer2Peer,
|
||||
@ -224,9 +231,22 @@ bool Session::premium() const {
|
||||
}
|
||||
|
||||
bool Session::premiumPossible() const {
|
||||
return !premium() && !_account->appConfig().get<bool>(
|
||||
"premium_purchase_blocked",
|
||||
true);
|
||||
return premium() || _premiumPossible.current();
|
||||
}
|
||||
|
||||
rpl::producer<bool> Session::premiumPossibleValue() const {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
auto premium = _user->flagsValue(
|
||||
) | rpl::filter([=](UserData::Flags::Change change) {
|
||||
return (change.diff & UserDataFlag::Premium);
|
||||
}) | rpl::map([=] {
|
||||
return _user->isPremium();
|
||||
});
|
||||
return rpl::combine(
|
||||
std::move(premium),
|
||||
_premiumPossible.value(),
|
||||
_1 || _2);
|
||||
}
|
||||
|
||||
uint64 Session::uniqueId() const {
|
||||
|
@ -82,6 +82,8 @@ public:
|
||||
|
||||
[[nodiscard]] bool premium() const;
|
||||
[[nodiscard]] bool premiumPossible() const;
|
||||
[[nodiscard]] rpl::producer<bool> premiumPossibleValue() const;
|
||||
|
||||
[[nodiscard]] uint64 uniqueId() const; // userId() with TestDC shift.
|
||||
[[nodiscard]] UserId userId() const;
|
||||
[[nodiscard]] PeerId userPeerId() const;
|
||||
@ -208,6 +210,7 @@ private:
|
||||
const std::unique_ptr<Support::Helper> _supportHelper;
|
||||
|
||||
std::shared_ptr<Data::CloudImageView> _selfUserpicView;
|
||||
rpl::variable<bool> _premiumPossible = false;
|
||||
|
||||
rpl::event_stream<bool> _termsLockChanges;
|
||||
std::unique_ptr<Window::TermsLock> _termsLock;
|
||||
|
@ -104,10 +104,6 @@ profileLimitReachedSkip: 6px;
|
||||
|
||||
profileMemberPaddingLeft: 16px;
|
||||
profileMemberNameFg: windowBoldFg;
|
||||
profileMemberCreatorIcon: icon {{ "profile_admin_star", profileAdminStartFg, point(4px, 3px) }};
|
||||
profileMemberCreatorIconOver: icon {{ "profile_admin_star", profileAdminStarFgOver, point(4px, 3px) }};
|
||||
profileMemberAdminIcon: icon {{ "profile_admin_star", profileOtherAdminStarFg, point(4px, 3px) }};
|
||||
profileMemberAdminIconOver: icon {{ "profile_admin_star", profileOtherAdminStarFgOver, point(4px, 3px) }};
|
||||
profileLimitReachedLabel: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 180px;
|
||||
margin: margins(profileMemberPaddingLeft, 9px, profileMemberPaddingLeft, 6px);
|
||||
|
@ -170,7 +170,8 @@ void GroupMembersWidget::updateItemStatusText(Item *item) {
|
||||
auto user = member->user();
|
||||
if (member->statusText.isEmpty() || (member->onlineTextTill <= _now)) {
|
||||
if (user->isBot()) {
|
||||
auto seesAllMessages = (user->botInfo->readsAllHistory || (member->adminState != Item::AdminState::None));
|
||||
const auto seesAllMessages = user->botInfo->readsAllHistory
|
||||
|| member->rank.has_value();
|
||||
member->statusText = seesAllMessages
|
||||
? tr::lng_status_bot_reads_all(tr::now)
|
||||
: tr::lng_status_bot_not_reads_all(tr::now);
|
||||
@ -294,25 +295,24 @@ void GroupMembersWidget::fillChatMembers(not_null<ChatData*> chat) {
|
||||
void GroupMembersWidget::setItemFlags(
|
||||
not_null<Item*> item,
|
||||
not_null<ChatData*> chat) {
|
||||
using AdminState = Item::AdminState;
|
||||
const auto user = getMember(item)->user();
|
||||
const auto isCreator = (peerFromUser(chat->creator) == item->peer->id);
|
||||
const auto isAdmin = (item->peer->isSelf() && chat->hasAdminRights())
|
||||
|| chat->admins.contains(user);
|
||||
const auto adminState = isCreator
|
||||
? AdminState::Creator
|
||||
const auto rank = isCreator
|
||||
? tr::lng_owner_badge(tr::now)
|
||||
: isAdmin
|
||||
? AdminState::Admin
|
||||
: AdminState::None;
|
||||
item->adminState = adminState;
|
||||
? tr::lng_admin_badge(tr::now)
|
||||
: std::optional<QString>();
|
||||
item->rank = rank;
|
||||
item->rankWidth = rank ? st::normalFont->width(*rank) : 0;
|
||||
if (item->peer->id == chat->session().userPeerId()) {
|
||||
item->hasRemoveLink = false;
|
||||
} else if (chat->amCreator()
|
||||
|| ((chat->adminRights() & ChatAdminRight::BanUsers)
|
||||
&& (adminState == AdminState::None))) {
|
||||
&& !rank.has_value())) {
|
||||
item->hasRemoveLink = true;
|
||||
} else if (chat->invitedByMe.contains(user)
|
||||
&& (adminState == AdminState::None)) {
|
||||
} else if (chat->invitedByMe.contains(user) && !rank.has_value()) {
|
||||
item->hasRemoveLink = true;
|
||||
} else {
|
||||
item->hasRemoveLink = false;
|
||||
@ -386,20 +386,27 @@ bool GroupMembersWidget::addUsersToEnd(not_null<ChannelData*> megagroup) {
|
||||
void GroupMembersWidget::setItemFlags(
|
||||
not_null<Item*> item,
|
||||
not_null<ChannelData*> megagroup) {
|
||||
using AdminState = Item::AdminState;
|
||||
auto amCreator = item->peer->isSelf() && megagroup->amCreator();
|
||||
auto amAdmin = item->peer->isSelf() && megagroup->hasAdminRights();
|
||||
auto adminIt = megagroup->mgInfo->lastAdmins.find(getMember(item)->user());
|
||||
auto isAdmin = (adminIt != megagroup->mgInfo->lastAdmins.cend());
|
||||
auto isCreator = megagroup->mgInfo->creator == item->peer;
|
||||
auto adminCanEdit = isAdmin && adminIt->second.canEdit;
|
||||
auto adminState = (amCreator || isCreator)
|
||||
? AdminState::Creator
|
||||
const auto amCreator = item->peer->isSelf() && megagroup->amCreator();
|
||||
const auto amAdmin = item->peer->isSelf() && megagroup->hasAdminRights();
|
||||
const auto user = getMember(item)->user();
|
||||
const auto adminIt = megagroup->mgInfo->lastAdmins.find(user);
|
||||
const auto isAdmin = (adminIt != megagroup->mgInfo->lastAdmins.cend());
|
||||
const auto isCreator = (megagroup->mgInfo->creator == item->peer);
|
||||
const auto rankIt = megagroup->mgInfo->admins.find(peerToUser(user->id));
|
||||
const auto adminCanEdit = isAdmin && adminIt->second.canEdit;
|
||||
const auto rank = (amCreator || isCreator)
|
||||
? (megagroup->mgInfo->creatorRank.isEmpty()
|
||||
? megagroup->mgInfo->creatorRank
|
||||
: tr::lng_owner_badge(tr::now))
|
||||
: (amAdmin || isAdmin)
|
||||
? AdminState::Admin
|
||||
: AdminState::None;
|
||||
if (item->adminState != adminState) {
|
||||
item->adminState = adminState;
|
||||
? ((rankIt != megagroup->mgInfo->admins.end()
|
||||
&& !rankIt->second.isEmpty())
|
||||
? rankIt->second
|
||||
: tr::lng_admin_badge(tr::now))
|
||||
: std::optional<QString>();
|
||||
if (item->rank != rank) {
|
||||
item->rank = rank;
|
||||
item->rankWidth = rank ? st::normalFont->width(*rank) : 0;
|
||||
auto user = item->peer->asUser();
|
||||
Assert(user != nullptr);
|
||||
if (user->isBot()) {
|
||||
@ -410,7 +417,9 @@ void GroupMembersWidget::setItemFlags(
|
||||
}
|
||||
if (item->peer->isSelf()) {
|
||||
item->hasRemoveLink = false;
|
||||
} else if (megagroup->amCreator() || (megagroup->canBanMembers() && ((adminState == AdminState::None) || adminCanEdit))) {
|
||||
} else if (megagroup->amCreator()
|
||||
|| (megagroup->canBanMembers()
|
||||
&& (!rank.has_value() || adminCanEdit))) {
|
||||
item->hasRemoveLink = true;
|
||||
} else {
|
||||
item->hasRemoveLink = false;
|
||||
|
@ -110,14 +110,11 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
|
||||
p.setPen(st::windowActiveTextFg);
|
||||
p.drawTextLeft(nameLeft + nameWidth - _removeWidth, nameTop, width(), _removeText, _removeWidth);
|
||||
nameWidth -= _removeWidth + skip;
|
||||
}
|
||||
if (item->adminState != Item::AdminState::None) {
|
||||
nameWidth -= st::profileMemberAdminIcon.width();
|
||||
auto iconLeft = nameLeft + qMin(nameWidth, item->name.maxWidth());
|
||||
auto &icon = (item->adminState == Item::AdminState::Creator)
|
||||
? (selected ? st::profileMemberCreatorIconOver : st::profileMemberCreatorIcon)
|
||||
: (selected ? st::profileMemberAdminIconOver : st::profileMemberAdminIcon);
|
||||
icon.paint(p, QPoint(iconLeft, nameTop), width());
|
||||
} else if (item->rank) {
|
||||
p.setFont(st::normalFont);
|
||||
p.setPen(st::windowActiveTextFg);
|
||||
p.drawTextLeft(nameLeft + nameWidth - item->rankWidth, nameTop, width(), *item->rank, item->rankWidth);
|
||||
nameWidth -= item->rankWidth + skip;
|
||||
}
|
||||
p.setPen(st::profileMemberNameFg);
|
||||
item->name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
|
||||
|
@ -37,12 +37,8 @@ public:
|
||||
Ui::Text::String name;
|
||||
QString statusText;
|
||||
bool statusHasOnlineColor = false;
|
||||
enum class AdminState {
|
||||
None,
|
||||
Admin,
|
||||
Creator,
|
||||
};
|
||||
AdminState adminState = AdminState::None;
|
||||
std::optional<QString> rank;
|
||||
int rankWidth = 0;
|
||||
bool hasRemoveLink = false;
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
};
|
||||
|
@ -927,17 +927,13 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
}, status->lifetime());
|
||||
|
||||
const auto session = &_controller->session();
|
||||
auto premiumPossible = session->account().appConfig().value(
|
||||
) | rpl::map([=] {
|
||||
return session->premiumPossible();
|
||||
});
|
||||
rpl::combine(
|
||||
terms->heightValue(),
|
||||
button->heightValue(),
|
||||
status->heightValue(),
|
||||
std::move(text),
|
||||
Data::AmPremiumValue(session),
|
||||
std::move(premiumPossible)
|
||||
session->premiumPossibleValue()
|
||||
) | rpl::start_with_next([=](
|
||||
int termsHeight,
|
||||
int buttonHeight,
|
||||
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/unread_badge.h"
|
||||
|
||||
#include "data/data_peer.h"
|
||||
#include "main/main_session.h"
|
||||
#include "dialogs/ui/dialogs_layout.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
@ -117,7 +118,9 @@ int DrawPeerBadgeGetWidth(
|
||||
rectForName.y(),
|
||||
outerWidth);
|
||||
return iconw;
|
||||
} else if (peer->isPremium() && st.premium) {
|
||||
} else if (peer->isPremium()
|
||||
&& st.premium
|
||||
&& peer->session().premiumPossible()) {
|
||||
const auto iconw = st.premium->width();
|
||||
st.premium->paint(
|
||||
p,
|
||||
|
Loading…
Reference in New Issue
Block a user