mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Add some more frozen restrictions.
This commit is contained in:
parent
a0764190f2
commit
f51320d1bc
15 changed files with 171 additions and 109 deletions
|
@ -111,6 +111,9 @@ void AddBotToGroupBoxController::Start(
|
|||
Scope scope,
|
||||
const QString &token,
|
||||
ChatAdminRights requestedRights) {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
auto initBox = [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
|
||||
};
|
||||
|
|
|
@ -2308,6 +2308,10 @@ void ChooseStarGiftRecipient(
|
|||
void ShowStarGiftBox(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<PeerData*> peer) {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct Session {
|
||||
PeerData *peer = nullptr;
|
||||
MyGiftsDescriptor my;
|
||||
|
|
|
@ -1354,102 +1354,8 @@ std::unique_ptr<Ui::AbstractButton> FrozenWriteRestriction(
|
|||
}
|
||||
}, title->lifetime());
|
||||
|
||||
const auto info = show->session().frozen();
|
||||
const auto detailsBox = [=](not_null<GenericBox*> box) {
|
||||
box->setWidth(st::boxWideWidth);
|
||||
box->setStyle(st::frozenInfoBox);
|
||||
box->setNoContentMargin(true);
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
||||
const auto content = box->verticalLayout();
|
||||
auto icon = Settings::CreateLottieIcon(
|
||||
content,
|
||||
{
|
||||
.name = u"media_forbidden"_q,
|
||||
.sizeOverride = {
|
||||
st::changePhoneIconSize,
|
||||
st::changePhoneIconSize,
|
||||
},
|
||||
},
|
||||
st::settingLocalPasscodeIconPadding);
|
||||
content->add(std::move(icon.widget));
|
||||
box->setShowFinishedCallback([animate = std::move(icon.animate)] {
|
||||
animate(anim::repeat::once);
|
||||
});
|
||||
|
||||
Ui::AddSkip(content);
|
||||
|
||||
const auto infoRow = [&](
|
||||
rpl::producer<QString> title,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
not_null<const style::icon*> icon) {
|
||||
auto raw = content->add(
|
||||
object_ptr<Ui::VerticalLayout>(content));
|
||||
raw->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(title) | Ui::Text::ToBold(),
|
||||
st.infoTitle ? *st.infoTitle : st::defaultFlatLabel),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
raw->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(text),
|
||||
st.infoAbout ? *st.infoAbout : st::upgradeGiftSubtext),
|
||||
st::settingsPremiumRowAboutPadding);
|
||||
object_ptr<Info::Profile::FloatingIcon>(
|
||||
raw,
|
||||
*icon,
|
||||
st::starrefInfoIconPosition);
|
||||
};
|
||||
|
||||
content->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
content,
|
||||
tr::lng_frozen_title(),
|
||||
st.title ? *st.title : st::uniqueGiftTitle),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
|
||||
Ui::AddSkip(content, st::defaultVerticalListSkip * 3);
|
||||
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle1(),
|
||||
tr::lng_frozen_text1(Text::WithEntities),
|
||||
st.violationIcon ? st.violationIcon : &st::menuIconBlock);
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle2(),
|
||||
tr::lng_frozen_text2(Text::WithEntities),
|
||||
st.readOnlyIcon ? st.readOnlyIcon : &st::menuIconLock);
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle3(),
|
||||
tr::lng_frozen_text3(
|
||||
lt_link,
|
||||
rpl::single(Text::Link(u"@SpamBot"_q, info.appealUrl)),
|
||||
lt_date,
|
||||
rpl::single(TextWithEntities{
|
||||
langDayOfMonthFull(
|
||||
base::unixtime::parse(info.until).date()),
|
||||
}),
|
||||
Text::WithEntities),
|
||||
st.appealIcon ? st.appealIcon : &st::menuIconHourglass);
|
||||
|
||||
const auto button = box->addButton(
|
||||
tr::lng_frozen_appeal_button(),
|
||||
[url = info.appealUrl] { UrlClickHandler::Open(url); });
|
||||
const auto buttonPadding = st::frozenInfoBox.buttonPadding;
|
||||
const auto buttonWidth = st::boxWideWidth
|
||||
- buttonPadding.left()
|
||||
- buttonPadding.right();
|
||||
button->widthValue() | rpl::filter([=] {
|
||||
return (button->widthNoMargins() != buttonWidth);
|
||||
}) | rpl::start_with_next([=] {
|
||||
button->resizeToWidth(buttonWidth);
|
||||
}, button->lifetime());
|
||||
};
|
||||
raw->setClickedCallback([=] {
|
||||
show->show(Box(detailsBox));
|
||||
show->show(Box(FrozenInfoBox, &show->session(), st));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
@ -1501,3 +1407,101 @@ rpl::producer<TextWithEntities> PaidSendButtonText(
|
|||
return PaidSendButtonText(tr::now, count);
|
||||
});
|
||||
}
|
||||
|
||||
void FrozenInfoBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
FreezeInfoStyleOverride st) {
|
||||
box->setWidth(st::boxWideWidth);
|
||||
box->setStyle(st::frozenInfoBox);
|
||||
box->setNoContentMargin(true);
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
||||
const auto info = session->frozen();
|
||||
const auto content = box->verticalLayout();
|
||||
auto icon = Settings::CreateLottieIcon(
|
||||
content,
|
||||
{
|
||||
.name = u"media_forbidden"_q,
|
||||
.sizeOverride = {
|
||||
st::changePhoneIconSize,
|
||||
st::changePhoneIconSize,
|
||||
},
|
||||
},
|
||||
st::settingLocalPasscodeIconPadding);
|
||||
content->add(std::move(icon.widget));
|
||||
box->setShowFinishedCallback([animate = std::move(icon.animate)] {
|
||||
animate(anim::repeat::once);
|
||||
});
|
||||
|
||||
Ui::AddSkip(content);
|
||||
|
||||
const auto infoRow = [&](
|
||||
rpl::producer<QString> title,
|
||||
rpl::producer<TextWithEntities> text,
|
||||
not_null<const style::icon*> icon) {
|
||||
auto raw = content->add(
|
||||
object_ptr<Ui::VerticalLayout>(content));
|
||||
raw->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(title) | Ui::Text::ToBold(),
|
||||
st.infoTitle ? *st.infoTitle : st::defaultFlatLabel),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
raw->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(text),
|
||||
st.infoAbout ? *st.infoAbout : st::upgradeGiftSubtext),
|
||||
st::settingsPremiumRowAboutPadding);
|
||||
object_ptr<Info::Profile::FloatingIcon>(
|
||||
raw,
|
||||
*icon,
|
||||
st::starrefInfoIconPosition);
|
||||
};
|
||||
|
||||
content->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
content,
|
||||
tr::lng_frozen_title(),
|
||||
st.title ? *st.title : st::uniqueGiftTitle),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
|
||||
Ui::AddSkip(content, st::defaultVerticalListSkip * 3);
|
||||
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle1(),
|
||||
tr::lng_frozen_text1(Ui::Text::WithEntities),
|
||||
st.violationIcon ? st.violationIcon : &st::menuIconBlock);
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle2(),
|
||||
tr::lng_frozen_text2(Ui::Text::WithEntities),
|
||||
st.readOnlyIcon ? st.readOnlyIcon : &st::menuIconLock);
|
||||
infoRow(
|
||||
tr::lng_frozen_subtitle3(),
|
||||
tr::lng_frozen_text3(
|
||||
lt_link,
|
||||
rpl::single(Ui::Text::Link(u"@SpamBot"_q, info.appealUrl)),
|
||||
lt_date,
|
||||
rpl::single(TextWithEntities{
|
||||
langDayOfMonthFull(
|
||||
base::unixtime::parse(info.until).date()),
|
||||
}),
|
||||
Ui::Text::WithEntities),
|
||||
st.appealIcon ? st.appealIcon : &st::menuIconHourglass);
|
||||
|
||||
const auto button = box->addButton(
|
||||
tr::lng_frozen_appeal_button(),
|
||||
[url = info.appealUrl] { UrlClickHandler::Open(url); });
|
||||
const auto buttonPadding = st::frozenInfoBox.buttonPadding;
|
||||
const auto buttonWidth = st::boxWideWidth
|
||||
- buttonPadding.left()
|
||||
- buttonPadding.right();
|
||||
button->widthValue() | rpl::filter([=] {
|
||||
return (button->widthNoMargins() != buttonWidth);
|
||||
}) | rpl::start_with_next([=] {
|
||||
button->resizeToWidth(buttonWidth);
|
||||
}, button->lifetime());
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ struct WriteRestriction;
|
|||
} // namespace HistoryView::Controls
|
||||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
class PopupMenu;
|
||||
class Show;
|
||||
} // namespace Ui
|
||||
|
@ -210,3 +211,8 @@ void SelectTextInFieldWithMargins(
|
|||
[[nodiscard]] rpl::producer<TextWithEntities> PaidSendButtonText(
|
||||
rpl::producer<int> stars,
|
||||
rpl::producer<QString> fallback = nullptr);
|
||||
|
||||
void FrozenInfoBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session,
|
||||
FreezeInfoStyleOverride st);
|
||||
|
|
|
@ -621,7 +621,9 @@ void HistoryInner::setupSwipeReplyAndBack() {
|
|||
}
|
||||
|
||||
bool HistoryInner::hasSelectRestriction() const {
|
||||
if (!_sharingDisallowed.current()) {
|
||||
if (session().frozen()) {
|
||||
return true;
|
||||
} else if (!_sharingDisallowed.current()) {
|
||||
return false;
|
||||
} else if (const auto chat = _peer->asChat()) {
|
||||
return !chat->canDeleteMessages();
|
||||
|
|
|
@ -1646,8 +1646,9 @@ bool ListWidget::showCopyRestrictionForSelected() {
|
|||
}
|
||||
|
||||
bool ListWidget::hasSelectRestriction() const {
|
||||
return _delegate->listSelectRestrictionType()
|
||||
!= CopyRestrictionType::None;
|
||||
return session().frozen()
|
||||
|| (_delegate->listSelectRestrictionType()
|
||||
!= CopyRestrictionType::None);
|
||||
}
|
||||
|
||||
Element *ListWidget::lookupItemByY(int y) const {
|
||||
|
|
|
@ -294,6 +294,9 @@ not_null<Ui::SettingsButton*> AddPeerGiftsButton(
|
|||
},
|
||||
tracker)->entity();
|
||||
result->addClickHandler([=] {
|
||||
if (navigation->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
navigation->showSection(
|
||||
std::make_shared<Info::Memento>(
|
||||
peer,
|
||||
|
|
|
@ -62,7 +62,9 @@ Type Provider::type() {
|
|||
}
|
||||
|
||||
bool Provider::hasSelectRestriction() {
|
||||
if (_peer->allowsForwarding()) {
|
||||
if (_peer->session().frozen()) {
|
||||
return true;
|
||||
} else if (_peer->allowsForwarding()) {
|
||||
return false;
|
||||
} else if (const auto chat = _peer->asChat()) {
|
||||
return !chat->canDeleteMessages();
|
||||
|
|
|
@ -2335,11 +2335,17 @@ void ActionsFiller::addShareContactAction(not_null<UserData*> user) {
|
|||
|
||||
void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
||||
const auto controller = _controller->parentController();
|
||||
const auto edit = [=] {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
controller->window().show(Box(EditContactBox, controller, user));
|
||||
};
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_info_edit_contact(),
|
||||
IsContactValue(user),
|
||||
[=] { controller->window().show(Box(EditContactBox, controller, user)); },
|
||||
edit,
|
||||
&st::infoIconEdit);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,9 @@ Type Provider::type() {
|
|||
}
|
||||
|
||||
bool Provider::hasSelectRestriction() {
|
||||
if (const auto channel = _peer->asChannel()) {
|
||||
if (_peer->session().frozen()) {
|
||||
return true;
|
||||
} else if (const auto channel = _peer->asChannel()) {
|
||||
return !channel->canEditStories() && !channel->canDeleteStories();
|
||||
}
|
||||
return !_peer->isSelf();
|
||||
|
|
|
@ -7,8 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "main/session/session_show.h"
|
||||
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
|
||||
namespace Main {
|
||||
namespace {
|
||||
|
@ -77,7 +79,7 @@ bool SessionShow::showFrozenError() {
|
|||
if (!session().frozen()) {
|
||||
return false;
|
||||
}
|
||||
showToast(tr::lng_frozen_bar_title(tr::now));
|
||||
showBox(Box(FrozenInfoBox, &session(), FreezeInfoStyleOverride()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_peer.h"
|
||||
#include "data/data_user.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/session/session_show.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_ttl.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
|
@ -133,6 +134,9 @@ const style::icon *TTLValidator::icon() const {
|
|||
}
|
||||
|
||||
void TTLValidator::showBox() const {
|
||||
if (Main::MakeSessionShow(_show, &_peer->session())->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
_show->showBox(Box(TTLBox, createArgs()));
|
||||
}
|
||||
|
||||
|
|
|
@ -781,7 +781,7 @@ void Filler::addBlockUser() {
|
|||
|| user->isVerifyCodes()) {
|
||||
return;
|
||||
}
|
||||
const auto window = &_controller->window();
|
||||
const auto window = _controller;
|
||||
const auto blockText = [](not_null<UserData*> user) {
|
||||
return user->isBlocked()
|
||||
? ((user->isBot() && !user->isSupport())
|
||||
|
@ -793,14 +793,16 @@ void Filler::addBlockUser() {
|
|||
};
|
||||
const auto blockAction = _addAction(blockText(user), [=] {
|
||||
const auto show = window->uiShow();
|
||||
if (user->isBlocked()) {
|
||||
if (show->showFrozenError()) {
|
||||
return;
|
||||
} else if (user->isBlocked()) {
|
||||
PeerMenuUnblockUserWithBotRestart(show, user);
|
||||
} else if (user->isBot()) {
|
||||
user->session().api().blockedPeers().block(user);
|
||||
} else {
|
||||
window->show(Box(
|
||||
PeerMenuBlockUserBox,
|
||||
window,
|
||||
&window->window(),
|
||||
user,
|
||||
v::null,
|
||||
v::null));
|
||||
|
@ -897,9 +899,15 @@ void Filler::addNewContact() {
|
|||
return;
|
||||
}
|
||||
const auto controller = _controller;
|
||||
const auto edit = [=] {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
controller->show(Box(EditContactBox, controller, user));
|
||||
};
|
||||
_addAction(
|
||||
tr::lng_info_add_as_contact(tr::now),
|
||||
[=] { controller->show(Box(EditContactBox, controller, user)); },
|
||||
edit,
|
||||
&st::menuIconInvite);
|
||||
}
|
||||
|
||||
|
@ -921,9 +929,15 @@ void Filler::addEditContact() {
|
|||
return;
|
||||
}
|
||||
const auto controller = _controller;
|
||||
const auto edit = [=] {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
controller->show(Box(EditContactBox, controller, user));
|
||||
};
|
||||
_addAction(
|
||||
tr::lng_info_edit_contact(tr::now),
|
||||
[=] { controller->show(Box(EditContactBox, controller, user)); },
|
||||
edit,
|
||||
&st::menuIconEdit);
|
||||
}
|
||||
|
||||
|
@ -1528,6 +1542,9 @@ void PeerMenuExportChat(
|
|||
void PeerMenuDeleteContact(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<UserData*> user) {
|
||||
if (controller->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
const auto text = tr::lng_sure_delete_contact(
|
||||
tr::now,
|
||||
lt_contact,
|
||||
|
@ -1624,6 +1641,9 @@ void PeerMenuDeleteTopic(
|
|||
void PeerMenuShareContactBox(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<UserData*> user) {
|
||||
if (navigation->showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
// There is no async to make weak from controller.
|
||||
const auto weak = std::make_shared<QPointer<Ui::BoxContent>>();
|
||||
auto callback = [=](not_null<Data::Thread*> thread) {
|
||||
|
|
|
@ -2541,7 +2541,10 @@ void SessionController::showInNewWindow(
|
|||
|
||||
void SessionController::toggleChooseChatTheme(
|
||||
not_null<PeerData*> peer,
|
||||
std::optional<bool> show) const {
|
||||
std::optional<bool> show) {
|
||||
if (showFrozenError()) {
|
||||
return;
|
||||
}
|
||||
content()->toggleChooseChatTheme(peer, show);
|
||||
}
|
||||
|
||||
|
|
|
@ -527,7 +527,7 @@ public:
|
|||
|
||||
void toggleChooseChatTheme(
|
||||
not_null<PeerData*> peer,
|
||||
std::optional<bool> show = std::nullopt) const;
|
||||
std::optional<bool> show = std::nullopt);
|
||||
void finishChatThemeEdit(not_null<PeerData*> peer);
|
||||
|
||||
[[nodiscard]] bool mainSectionShown() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue