Rename restrictionReason to unavailableReason.

This commit is contained in:
John Preston 2019-01-04 11:57:07 +04:00
parent d2d6b319b6
commit 0ce4d66601
6 changed files with 45 additions and 43 deletions

View File

@ -474,10 +474,16 @@ bool UserData::setAbout(const QString &newAbout) {
return true;
}
void UserData::setRestrictionReason(const QString &text) {
if (_restrictionReason != text) {
_restrictionReason = text;
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::RestrictionReasonChanged);
QString UserData::unavailableReason() const {
return _unavailableReason;
}
void UserData::setUnavailableReason(const QString &text) {
if (_unavailableReason != text) {
_unavailableReason = text;
Notify::peerUpdatedDelayed(
this,
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
}
}
@ -924,10 +930,16 @@ bool ChannelData::isGroupAdmin(not_null<UserData*> user) const {
return false;
}
void ChannelData::setRestrictionReason(const QString &text) {
if (_restrictionReason != text) {
_restrictionReason = text;
Notify::peerUpdatedDelayed(this, Notify::PeerUpdate::Flag::RestrictionReasonChanged);
QString ChannelData::unavailableReason() const {
return _unavailableReason;
}
void ChannelData::setUnavailableReason(const QString &text) {
if (_unavailableReason != text) {
_unavailableReason = text;
Notify::peerUpdatedDelayed(
this,
Notify::PeerUpdate::Flag::UnavailableReasonChanged);
}
}

View File

@ -199,9 +199,9 @@ public:
int nameVersion = 1;
// if this string is not empty we must not allow to open the
// conversation and we must show this string instead
virtual QString restrictionReason() const {
// If this string is not empty we must not allow to open the
// conversation and we must show this string instead.
virtual QString unavailableReason() const {
return QString();
}
@ -467,10 +467,8 @@ public:
std::unique_ptr<BotInfo> botInfo;
QString restrictionReason() const override {
return _restrictionReason;
}
void setRestrictionReason(const QString &reason);
QString unavailableReason() const override;
void setUnavailableReason(const QString &reason);
int commonChatsCount() const {
return _commonChatsCount;
@ -481,7 +479,7 @@ private:
Flags _flags;
FullFlags _fullFlags;
QString _restrictionReason;
QString _unavailableReason;
QString _about;
QString _phone;
ContactStatus _contactStatus = ContactStatus::PhoneUnknown;
@ -991,10 +989,8 @@ public:
return _ptsWaiter.waitingForShortPoll();
}
QString restrictionReason() const override {
return _restrictionReason;
}
void setRestrictionReason(const QString &reason);
QString unavailableReason() const override;
void setUnavailableReason(const QString &reason);
MsgId availableMinId() const {
return _availableMinId;
@ -1030,7 +1026,7 @@ private:
RestrictionFlags _restrictions;
TimeId _restrictedUntill;
QString _restrictionReason;
QString _unavailableReason;
QString _about;
QString _inviteLink;

View File

@ -96,7 +96,7 @@ void CheckForSwitchInlineButton(not_null<HistoryItem*> item) {
// We should get a full restriction in "{full}: {reason}" format and we
// need to find an "-all" tag in {full}, otherwise ignore this restriction.
QString ExtractRestrictionReason(const QString &restriction) {
QString ExtractUnavailableReason(const QString &restriction) {
const auto fullEnd = restriction.indexOf(':');
if (fullEnd <= 0) {
return QString();
@ -278,12 +278,9 @@ not_null<UserData*> Session::user(const MTPUser &data) {
result->input = MTP_inputPeerUser(data.vid, data.vaccess_hash);
result->inputUser = MTP_inputUser(data.vid, data.vaccess_hash);
}
if (data.is_restricted()) {
result->setRestrictionReason(
ExtractRestrictionReason(qs(data.vrestriction_reason)));
} else {
result->setRestrictionReason(QString());
}
result->setUnavailableReason(data.is_restricted()
? ExtractUnavailableReason(qs(data.vrestriction_reason))
: QString());
}
if (data.is_deleted()) {
if (!result->phone().isEmpty()) {
@ -554,12 +551,9 @@ not_null<PeerData*> Session::chat(const MTPChat &data) {
if (channel->version < data.vversion.v) {
channel->version = data.vversion.v;
}
if (data.is_restricted()) {
channel->setRestrictionReason(
ExtractRestrictionReason(qs(data.vrestriction_reason)));
} else {
channel->setRestrictionReason(QString());
}
channel->setUnavailableReason(data.is_restricted()
? ExtractUnavailableReason(qs(data.vrestriction_reason))
: QString());
channel->setFlags(data.vflags.v);
//if (data.has_feed_id()) { // #feed
// channel->setFeed(feed(data.vfeed_id.v));

View File

@ -406,7 +406,7 @@ HistoryWidget::HistoryWidget(
| UpdateFlag::UnreadMentionsChanged
| UpdateFlag::UnreadViewChanged
| UpdateFlag::MigrationChanged
| UpdateFlag::RestrictionReasonChanged
| UpdateFlag::UnavailableReasonChanged
| UpdateFlag::PinnedMessageChanged
| UpdateFlag::UserIsBlocked
| UpdateFlag::AdminsChanged
@ -436,11 +436,11 @@ HistoryWidget::HistoryWidget(
if (update.flags & UpdateFlag::NotificationsEnabled) {
updateNotifyControls();
}
if (update.flags & UpdateFlag::RestrictionReasonChanged) {
auto restriction = _peer->restrictionReason();
if (!restriction.isEmpty()) {
if (update.flags & UpdateFlag::UnavailableReasonChanged) {
const auto unavailable = _peer->unavailableReason();
if (!unavailable.isEmpty()) {
this->controller()->showBackFromStack();
Ui::show(Box<InformBox>(restriction));
Ui::show(Box<InformBox>(unavailable));
return;
}
}

View File

@ -1593,10 +1593,10 @@ void MainWidget::ui_showPeerHistory(
peerId = peer->id;
if (showAtMsgId > 0) showAtMsgId = -showAtMsgId;
}
auto restriction = peer->restrictionReason();
if (!restriction.isEmpty()) {
const auto unavailable = peer->unavailableReason();
if (!unavailable.isEmpty()) {
if (params.activation != anim::activation::background) {
Ui::show(Box<InformBox>(restriction));
Ui::show(Box<InformBox>(unavailable));
}
return;
}

View File

@ -36,7 +36,7 @@ struct PeerUpdate {
NotificationsEnabled = (1 << 4),
MigrationChanged = (1 << 6),
ChatPinnedChanged = (1 << 7),
RestrictionReasonChanged = (1 << 8),
UnavailableReasonChanged = (1 << 8),
UnreadViewChanged = (1 << 9),
PinnedMessageChanged = (1 << 10),