mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Remove some MainWindow::sessionController() calls.
This commit is contained in:
parent
4d65df6ca2
commit
30c82bb2e0
35 changed files with 275 additions and 182 deletions
Telegram/SourceFiles
apiwrap.cppapiwrap.h
boxes
background_preview_box.cpp
peers
add_participants_box.cppedit_contact_box.cppedit_contact_box.hedit_peer_info_box.cppedit_peer_permissions_box.cppedit_peer_permissions_box.h
stickers_box.cppstickers_box.hchat_helpers
history
info/profile
media/view
settings
support
window
|
@ -2708,39 +2708,6 @@ void ApiWrap::resolveWebPages() {
|
|||
}
|
||||
}
|
||||
|
||||
void ApiWrap::requestAttachedStickerSets(not_null<PhotoData*> photo) {
|
||||
request(_attachedStickerSetsRequestId).cancel();
|
||||
_attachedStickerSetsRequestId = request(MTPmessages_GetAttachedStickers(
|
||||
MTP_inputStickeredMediaPhoto(photo->mtpInput())
|
||||
)).done([=](const MTPVector<MTPStickerSetCovered> &result) {
|
||||
if (result.v.isEmpty()) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
return;
|
||||
} else if (result.v.size() > 1) {
|
||||
Ui::show(Box<StickersBox>(_session, result));
|
||||
return;
|
||||
}
|
||||
// Single attached sticker pack.
|
||||
const auto setData = result.v.front().match([&](const auto &data) {
|
||||
return data.vset().match([&](const MTPDstickerSet &data) {
|
||||
return &data;
|
||||
});
|
||||
});
|
||||
|
||||
const auto setId = (setData->vid().v && setData->vaccess_hash().v)
|
||||
? MTP_inputStickerSetID(setData->vid(), setData->vaccess_hash())
|
||||
: MTP_inputStickerSetShortName(setData->vshort_name());
|
||||
const auto &windows = _session->windows();
|
||||
if (!windows.empty()) {
|
||||
Ui::show(
|
||||
Box<StickerSetBox>(windows.front(), setId),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::requestParticipantsCountDelayed(
|
||||
not_null<ChannelData*> channel) {
|
||||
_participantsCountRequestTimer.call(
|
||||
|
|
|
@ -262,7 +262,6 @@ public:
|
|||
void clearWebPageRequest(WebPageData *page);
|
||||
void clearWebPageRequests();
|
||||
|
||||
void requestAttachedStickerSets(not_null<PhotoData*> photo);
|
||||
void scheduleStickerSetRequest(uint64 setId, uint64 access);
|
||||
void requestStickerSets();
|
||||
void saveStickerSets(
|
||||
|
@ -847,8 +846,6 @@ private:
|
|||
std::optional<bool> _contactSignupSilent;
|
||||
rpl::event_stream<bool> _contactSignupSilentChanges;
|
||||
|
||||
mtpRequestId _attachedStickerSetsRequestId = 0;
|
||||
|
||||
base::flat_map<FullMsgId, QString> _unlikelyMessageLinks;
|
||||
|
||||
};
|
||||
|
|
|
@ -399,7 +399,8 @@ BackgroundPreviewBox::BackgroundPreviewBox(
|
|||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
const Data::WallPaper &paper)
|
||||
: _controller(controller)
|
||||
: SimpleElementDelegate(controller)
|
||||
, _controller(controller)
|
||||
, _text1(GenerateTextItem(
|
||||
delegate(),
|
||||
_controller->session().data().history(
|
||||
|
|
|
@ -244,7 +244,7 @@ void AddParticipantsBoxController::Start(
|
|||
box->boxClosing() | rpl::start_with_next([=] {
|
||||
auto params = Window::SectionShow();
|
||||
params.activation = anim::activation::background;
|
||||
App::wnd()->sessionController()->showPeerHistory(
|
||||
navigation->parentController()->showPeerHistory(
|
||||
channel,
|
||||
params,
|
||||
ShowAtTheEndMsgId);
|
||||
|
|
|
@ -83,7 +83,7 @@ class Controller {
|
|||
public:
|
||||
Controller(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<UserData*> user);
|
||||
|
||||
void prepare();
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
bool inverted);
|
||||
|
||||
not_null<Ui::GenericBox*> _box;
|
||||
not_null<Window::Controller*> _window;
|
||||
not_null<Window::SessionController*> _window;
|
||||
not_null<UserData*> _user;
|
||||
Ui::Checkbox *_sharePhone = nullptr;
|
||||
QString _phone;
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
|
||||
Controller::Controller(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<UserData*> user)
|
||||
: _box(box)
|
||||
, _window(window)
|
||||
|
@ -143,7 +143,7 @@ void Controller::setupCover() {
|
|||
object_ptr<Info::Profile::Cover>(
|
||||
_box,
|
||||
_user,
|
||||
_window->sessionController(),
|
||||
_window,
|
||||
(_phone.isEmpty()
|
||||
? tr::lng_contact_mobile_hidden()
|
||||
: rpl::single(App::formatPhone(_phone)))),
|
||||
|
@ -266,7 +266,7 @@ void Controller::setupSharePhoneNumber() {
|
|||
|
||||
void EditContactBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<UserData*> user) {
|
||||
box->lifetime().make_state<Controller>(box, window, user)->prepare();
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
class UserData;
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
void EditContactBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<UserData*> user);
|
||||
|
|
|
@ -193,9 +193,11 @@ void SaveSlowmodeSeconds(
|
|||
api->registerModifyRequest(key, requestId);
|
||||
}
|
||||
|
||||
void ShowEditPermissions(not_null<PeerData*> peer) {
|
||||
void ShowEditPermissions(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer) {
|
||||
const auto box = Ui::show(
|
||||
Box<EditPeerPermissionsBox>(peer),
|
||||
Box<EditPeerPermissionsBox>(navigation, peer),
|
||||
Ui::LayerOption::KeepOther);
|
||||
const auto saving = box->lifetime().make_state<int>(0);
|
||||
const auto save = [=](
|
||||
|
@ -562,7 +564,9 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
|
|||
tr::lng_group_stickers_add(tr::now),
|
||||
st::editPeerInviteLinkButton)
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<StickersBox>(channel), Ui::LayerOption::KeepOther);
|
||||
Ui::show(
|
||||
Box<StickersBox>(_navigation->parentController(), channel),
|
||||
Ui::LayerOption::KeepOther);
|
||||
});
|
||||
|
||||
return result;
|
||||
|
@ -831,8 +835,6 @@ void Controller::fillHistoryVisibilityButton() {
|
|||
void Controller::fillManageSection() {
|
||||
Expects(_controls.buttonsLayout != nullptr);
|
||||
|
||||
const auto navigation = App::wnd()->sessionController();
|
||||
|
||||
const auto chat = _peer->asChat();
|
||||
const auto channel = _peer->asChannel();
|
||||
const auto isChannel = (!chat);
|
||||
|
@ -944,7 +946,7 @@ void Controller::fillManageSection() {
|
|||
Info::Profile::RestrictionsCountValue
|
||||
) | rpl::flatten_latest(
|
||||
) | ToPositiveNumberStringRestrictions(),
|
||||
[=] { ShowEditPermissions(_peer); },
|
||||
[=] { ShowEditPermissions(_navigation, _peer); },
|
||||
st::infoIconPermissions);
|
||||
}
|
||||
if (canViewAdmins) {
|
||||
|
@ -959,7 +961,7 @@ void Controller::fillManageSection() {
|
|||
) | ToPositiveNumberString(),
|
||||
[=] {
|
||||
ParticipantsBoxController::Start(
|
||||
navigation,
|
||||
_navigation,
|
||||
_peer,
|
||||
ParticipantsBoxController::Role::Admins);
|
||||
},
|
||||
|
@ -977,7 +979,7 @@ void Controller::fillManageSection() {
|
|||
) | ToPositiveNumberString(),
|
||||
[=] {
|
||||
ParticipantsBoxController::Start(
|
||||
navigation,
|
||||
_navigation,
|
||||
_peer,
|
||||
ParticipantsBoxController::Role::Members);
|
||||
},
|
||||
|
@ -991,7 +993,7 @@ void Controller::fillManageSection() {
|
|||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
ParticipantsBoxController::Start(
|
||||
navigation,
|
||||
_navigation,
|
||||
_peer,
|
||||
ParticipantsBoxController::Role::Kicked);
|
||||
},
|
||||
|
@ -1003,7 +1005,7 @@ void Controller::fillManageSection() {
|
|||
tr::lng_manage_peer_recent_actions(),
|
||||
rpl::single(QString()), //Empty count.
|
||||
[=] {
|
||||
navigation->showSection(AdminLog::SectionMemento(channel));
|
||||
_navigation->showSection(AdminLog::SectionMemento(channel));
|
||||
},
|
||||
st::infoIconRecentActions);
|
||||
}
|
||||
|
|
|
@ -307,8 +307,10 @@ ChatAdminRights FullAdminRights(bool isGroup) {
|
|||
|
||||
EditPeerPermissionsBox::EditPeerPermissionsBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer)
|
||||
: _peer(peer->migrateToOrMe()) {
|
||||
: _navigation(navigation)
|
||||
, _peer(peer->migrateToOrMe()) {
|
||||
}
|
||||
|
||||
auto EditPeerPermissionsBox::saveEvents() const -> rpl::producer<Result> {
|
||||
|
@ -522,8 +524,6 @@ void EditPeerPermissionsBox::addBannedButtons(
|
|||
}
|
||||
}
|
||||
const auto channel = _peer->asChannel();
|
||||
|
||||
const auto navigation = App::wnd()->sessionController();
|
||||
container->add(EditPeerInfoBox::CreateButton(
|
||||
container,
|
||||
tr::lng_manage_peer_exceptions(),
|
||||
|
@ -532,7 +532,7 @@ void EditPeerPermissionsBox::addBannedButtons(
|
|||
: rpl::single(0)) | ToPositiveNumberString(),
|
||||
[=] {
|
||||
ParticipantsBoxController::Start(
|
||||
navigation,
|
||||
_navigation,
|
||||
_peer,
|
||||
ParticipantsBoxController::Role::Restricted);
|
||||
},
|
||||
|
@ -545,7 +545,7 @@ void EditPeerPermissionsBox::addBannedButtons(
|
|||
| ToPositiveNumberString(),
|
||||
[=] {
|
||||
ParticipantsBoxController::Start(
|
||||
navigation,
|
||||
_navigation,
|
||||
_peer,
|
||||
ParticipantsBoxController::Role::Kicked);
|
||||
},
|
||||
|
|
|
@ -15,9 +15,16 @@ class RoundButton;
|
|||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
} // namespace Window
|
||||
|
||||
class EditPeerPermissionsBox : public Ui::BoxContent {
|
||||
public:
|
||||
EditPeerPermissionsBox(QWidget*, not_null<PeerData*> peer);
|
||||
EditPeerPermissionsBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
struct Result {
|
||||
MTPDchatBannedRights::Flags rights;
|
||||
|
@ -34,7 +41,8 @@ private:
|
|||
void addSlowmodeLabels(not_null<Ui::VerticalLayout*> container);
|
||||
void addBannedButtons(not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
not_null<PeerData*> _peer;
|
||||
const not_null<Window::SessionNavigation*> _navigation;
|
||||
const not_null<PeerData*> _peer;
|
||||
Ui::RoundButton *_save = nullptr;
|
||||
Fn<Result()> _value;
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
|
||||
// This class is hold in header because it requires Qt preprocessing.
|
||||
class StickersBox::Inner
|
||||
: public Ui::RpWidget
|
||||
|
@ -77,9 +76,14 @@ public:
|
|||
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Section section);
|
||||
Inner(QWidget *parent, not_null<ChannelData*> megagroup);
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> megagroup);
|
||||
|
||||
[[nodiscard]] Main::Session &session() const;
|
||||
|
||||
base::Observable<int> scrollToY;
|
||||
void setInnerFocus();
|
||||
|
@ -232,7 +236,7 @@ private:
|
|||
|
||||
int countMaxNameWidth() const;
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
MTP::Sender _api;
|
||||
|
||||
Section _section;
|
||||
|
@ -359,26 +363,29 @@ void StickersBox::Tab::saveScrollTop() {
|
|||
|
||||
StickersBox::StickersBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Section section)
|
||||
: _session(session)
|
||||
, _api(&session->mtp())
|
||||
: _controller(controller)
|
||||
, _api(&controller->session().mtp())
|
||||
, _tabs(this, st::stickersTabs)
|
||||
, _unreadBadge(
|
||||
this,
|
||||
_session->data().stickers().featuredSetsUnreadCountValue())
|
||||
controller->session().data().stickers().featuredSetsUnreadCountValue())
|
||||
, _section(section)
|
||||
, _installed(0, this, session, Section::Installed)
|
||||
, _featured(1, this, session, Section::Featured)
|
||||
, _archived(2, this, session, Section::Archived) {
|
||||
, _installed(0, this, controller, Section::Installed)
|
||||
, _featured(1, this, controller, Section::Featured)
|
||||
, _archived(2, this, controller, Section::Archived) {
|
||||
_tabs->setRippleTopRoundRadius(st::boxRadius);
|
||||
}
|
||||
|
||||
StickersBox::StickersBox(QWidget*, not_null<ChannelData*> megagroup)
|
||||
: _session(&megagroup->session())
|
||||
, _api(&_session->mtp())
|
||||
StickersBox::StickersBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> megagroup)
|
||||
: _controller(controller)
|
||||
, _api(&controller->session().mtp())
|
||||
, _section(Section::Installed)
|
||||
, _installed(0, this, megagroup)
|
||||
, _installed(0, this, controller, megagroup)
|
||||
, _megagroupSet(megagroup) {
|
||||
subscribe(_installed.widget()->scrollToY, [=](int y) {
|
||||
onScrollToY(y);
|
||||
|
@ -387,15 +394,19 @@ StickersBox::StickersBox(QWidget*, not_null<ChannelData*> megagroup)
|
|||
|
||||
StickersBox::StickersBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
const MTPVector<MTPStickerSetCovered> &attachedSets)
|
||||
: _session(session)
|
||||
, _api(&session->mtp())
|
||||
: _controller(controller)
|
||||
, _api(&controller->session().mtp())
|
||||
, _section(Section::Attached)
|
||||
, _attached(0, this, session, Section::Attached)
|
||||
, _attached(0, this, controller, Section::Attached)
|
||||
, _attachedSets(attachedSets) {
|
||||
}
|
||||
|
||||
Main::Session &StickersBox::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void StickersBox::showAttachedStickers() {
|
||||
auto addedSet = false;
|
||||
for (const auto &stickerSet : _attachedSets.v) {
|
||||
|
@ -405,11 +416,11 @@ void StickersBox::showAttachedStickers() {
|
|||
});
|
||||
});
|
||||
|
||||
if (const auto set = _session->data().stickers().feedSet(*setData)) {
|
||||
if (const auto set = session().data().stickers().feedSet(*setData)) {
|
||||
if (_attached.widget()->appendSet(set)) {
|
||||
addedSet = true;
|
||||
if (set->stickers.isEmpty() || (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||
_session->api().scheduleStickerSetRequest(set->id, set->access);
|
||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +430,7 @@ void StickersBox::showAttachedStickers() {
|
|||
}
|
||||
|
||||
if (_section == Section::Attached && addedSet) {
|
||||
_session->api().requestStickerSets();
|
||||
session().api().requestStickerSets();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,7 +444,7 @@ void StickersBox::getArchivedDone(
|
|||
}
|
||||
|
||||
auto &stickers = result.c_messages_archivedStickers();
|
||||
auto &archived = _session->data().stickers().archivedSetsOrderRef();
|
||||
auto &archived = session().data().stickers().archivedSetsOrderRef();
|
||||
if (offsetId) {
|
||||
auto index = archived.indexOf(offsetId);
|
||||
if (index >= 0) {
|
||||
|
@ -463,7 +474,7 @@ void StickersBox::getArchivedDone(
|
|||
}
|
||||
if (!setData) continue;
|
||||
|
||||
if (const auto set = _session->data().stickers().feedSet(*setData)) {
|
||||
if (const auto set = session().data().stickers().feedSet(*setData)) {
|
||||
const auto index = archived.indexOf(set->id);
|
||||
if (archived.isEmpty() || index != archived.size() - 1) {
|
||||
changedSets = true;
|
||||
|
@ -475,7 +486,7 @@ void StickersBox::getArchivedDone(
|
|||
if (_archived.widget()->appendSet(set)) {
|
||||
addedSet = true;
|
||||
if (set->stickers.isEmpty() || (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||
_session->api().scheduleStickerSetRequest(set->id, set->access);
|
||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -493,14 +504,14 @@ void StickersBox::getArchivedDone(
|
|||
refreshTabs();
|
||||
_someArchivedLoaded = true;
|
||||
if (_section == Section::Archived && addedSet) {
|
||||
_session->api().requestStickerSets();
|
||||
session().api().requestStickerSets();
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::prepare() {
|
||||
if (_section == Section::Installed) {
|
||||
if (_tabs) {
|
||||
_session->local().readArchivedStickers();
|
||||
session().local().readArchivedStickers();
|
||||
} else {
|
||||
setTitle(tr::lng_stickers_group_set());
|
||||
}
|
||||
|
@ -510,7 +521,7 @@ void StickersBox::prepare() {
|
|||
setTitle(tr::lng_stickers_attached_sets());
|
||||
}
|
||||
if (_tabs) {
|
||||
if (_session->data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
if (session().data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
preloadArchivedSets();
|
||||
}
|
||||
setNoContentMargin(true);
|
||||
|
@ -561,11 +572,11 @@ void StickersBox::prepare() {
|
|||
setInnerWidget(_tab->takeWidget(), getTopSkip());
|
||||
setDimensions(st::boxWideWidth, st::boxMaxListHeight);
|
||||
|
||||
_session->data().stickers().updated(
|
||||
session().data().stickers().updated(
|
||||
) | rpl::start_with_next(
|
||||
[this] { handleStickersUpdated(); },
|
||||
lifetime());
|
||||
_session->api().updateStickers();
|
||||
session().api().updateStickers();
|
||||
|
||||
if (_installed.widget()) {
|
||||
_installed.widget()->draggingScrollDelta(
|
||||
|
@ -593,11 +604,11 @@ void StickersBox::refreshTabs() {
|
|||
auto sections = QStringList();
|
||||
sections.push_back(tr::lng_stickers_installed_tab(tr::now).toUpper());
|
||||
_tabIndices.push_back(Section::Installed);
|
||||
if (!_session->data().stickers().featuredSetsOrder().isEmpty()) {
|
||||
if (!session().data().stickers().featuredSetsOrder().isEmpty()) {
|
||||
sections.push_back(tr::lng_stickers_featured_tab(tr::now).toUpper());
|
||||
_tabIndices.push_back(Section::Featured);
|
||||
}
|
||||
if (!_session->data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
if (!session().data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
sections.push_back(tr::lng_stickers_archived_tab(tr::now).toUpper());
|
||||
_tabIndices.push_back(Section::Archived);
|
||||
}
|
||||
|
@ -621,8 +632,8 @@ void StickersBox::loadMoreArchived() {
|
|||
}
|
||||
|
||||
uint64 lastId = 0;
|
||||
const auto &order = _session->data().stickers().archivedSetsOrder();
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &order = session().data().stickers().archivedSetsOrder();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
for (auto setIt = order.cend(), e = order.cbegin(); setIt != e;) {
|
||||
--setIt;
|
||||
auto it = sets.find(*setIt);
|
||||
|
@ -745,7 +756,7 @@ QPixmap StickersBox::grabContentCache() {
|
|||
}
|
||||
|
||||
void StickersBox::installSet(uint64 setId) {
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
const auto it = sets.find(setId);
|
||||
if (it == sets.cend()) {
|
||||
rebuildList();
|
||||
|
@ -771,24 +782,24 @@ void StickersBox::installSet(uint64 setId) {
|
|||
installFail(error, setId);
|
||||
}).send();
|
||||
|
||||
_session->data().stickers().installLocally(setId);
|
||||
session().data().stickers().installLocally(setId);
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::installDone(const MTPmessages_StickerSetInstallResult &result) {
|
||||
if (result.type() == mtpc_messages_stickerSetInstallResultArchive) {
|
||||
_session->data().stickers().applyArchivedResult(
|
||||
session().data().stickers().applyArchivedResult(
|
||||
result.c_messages_stickerSetInstallResultArchive());
|
||||
}
|
||||
}
|
||||
|
||||
void StickersBox::installFail(const RPCError &error, uint64 setId) {
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
const auto it = sets.find(setId);
|
||||
if (it == sets.cend()) {
|
||||
rebuildList();
|
||||
} else {
|
||||
_session->data().stickers().undoInstallLocally(setId);
|
||||
session().data().stickers().undoInstallLocally(setId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -813,18 +824,18 @@ void StickersBox::requestArchivedSets() {
|
|||
preloadArchivedSets();
|
||||
}
|
||||
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &order = _session->data().stickers().archivedSetsOrder();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
const auto &order = session().data().stickers().archivedSetsOrder();
|
||||
for (const auto setId : order) {
|
||||
auto it = sets.find(setId);
|
||||
if (it != sets.cend()) {
|
||||
const auto set = it->second.get();
|
||||
if (set->stickers.isEmpty() && (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||
_session->api().scheduleStickerSetRequest(setId, set->access);
|
||||
session().api().scheduleStickerSetRequest(setId, set->access);
|
||||
}
|
||||
}
|
||||
}
|
||||
_session->api().requestStickerSets();
|
||||
session().api().requestStickerSets();
|
||||
}
|
||||
|
||||
void StickersBox::resizeEvent(QResizeEvent *e) {
|
||||
|
@ -848,7 +859,7 @@ void StickersBox::handleStickersUpdated() {
|
|||
} else {
|
||||
_tab->widget()->updateRows();
|
||||
}
|
||||
if (_session->data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
if (session().data().stickers().archivedSetsOrder().isEmpty()) {
|
||||
preloadArchivedSets();
|
||||
} else {
|
||||
refreshTabs();
|
||||
|
@ -875,9 +886,9 @@ void StickersBox::saveChanges() {
|
|||
rebuildList(&_installed);
|
||||
|
||||
if (_someArchivedLoaded) {
|
||||
_session->local().writeArchivedStickers();
|
||||
session().local().writeArchivedStickers();
|
||||
}
|
||||
_session->api().saveStickerSets(_installed.widget()->getOrder(), _installed.widget()->getRemovedSets());
|
||||
session().api().saveStickerSets(_installed.widget()->getOrder(), _installed.widget()->getRemovedSets());
|
||||
}
|
||||
|
||||
void StickersBox::setInnerFocus() {
|
||||
|
@ -923,11 +934,11 @@ bool StickersBox::Inner::Row::isRecentSet() const {
|
|||
|
||||
StickersBox::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
StickersBox::Section section)
|
||||
: RpWidget(parent)
|
||||
, _session(session)
|
||||
, _api(&_session->mtp())
|
||||
, _controller(controller)
|
||||
, _api(&_controller->session().mtp())
|
||||
, _section(section)
|
||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||
, _shiftingAnimation([=](crl::time now) {
|
||||
|
@ -941,10 +952,13 @@ StickersBox::Inner::Inner(
|
|||
setup();
|
||||
}
|
||||
|
||||
StickersBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> megagroup)
|
||||
StickersBox::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> megagroup)
|
||||
: RpWidget(parent)
|
||||
, _session(&megagroup->session())
|
||||
, _api(&_session->mtp())
|
||||
, _controller(controller)
|
||||
, _api(&_controller->session().mtp())
|
||||
, _section(StickersBox::Section::Installed)
|
||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||
, _shiftingAnimation([=](crl::time now) {
|
||||
|
@ -958,11 +972,11 @@ StickersBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> megagroup)
|
|||
st::groupStickersField,
|
||||
rpl::single(qsl("stickerset")),
|
||||
QString(),
|
||||
_session->createInternalLink(QString()))
|
||||
_controller->session().createInternalLink(QString()))
|
||||
, _megagroupDivider(this)
|
||||
, _megagroupSubTitle(this, tr::lng_stickers_group_from_your(tr::now), st::boxTitle) {
|
||||
_megagroupSetField->setLinkPlaceholder(
|
||||
_session->createInternalLink(qsl("addstickers/")));
|
||||
_controller->session().createInternalLink(qsl("addstickers/")));
|
||||
_megagroupSetField->setPlaceholderHidden(false);
|
||||
_megagroupSetAddressChangedTimer.setCallback([this] { handleMegagroupSetAddressChange(); });
|
||||
connect(
|
||||
|
@ -983,8 +997,12 @@ StickersBox::Inner::Inner(QWidget *parent, not_null<ChannelData*> megagroup)
|
|||
setup();
|
||||
}
|
||||
|
||||
Main::Session &StickersBox::Inner::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void StickersBox::Inner::setup() {
|
||||
subscribe(_session->downloaderTaskFinished(), [this] {
|
||||
subscribe(session().downloaderTaskFinished(), [this] {
|
||||
update();
|
||||
readVisibleSets();
|
||||
});
|
||||
|
@ -1211,8 +1229,7 @@ void StickersBox::Inner::paintRowThumbnail(
|
|||
size.width(),
|
||||
size.height()),
|
||||
frame);
|
||||
const auto controller = App::wnd()->sessionController();
|
||||
const auto paused = controller->isGifPausedAtLeastFor(
|
||||
const auto paused = _controller->isGifPausedAtLeastFor(
|
||||
Window::GifPauseReason::Layer);
|
||||
if (!paused) {
|
||||
row->lottie->markFrameShown();
|
||||
|
@ -1571,9 +1588,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|||
const auto showSetByRow = [&](const Row &row) {
|
||||
setSelected(SelectedRow());
|
||||
Ui::show(
|
||||
Box<StickerSetBox>(
|
||||
App::wnd()->sessionController(),
|
||||
row.set->mtpInput()),
|
||||
Box<StickerSetBox>(_controller, row.set->mtpInput()),
|
||||
Ui::LayerOption::KeepOther);
|
||||
};
|
||||
if (selectedIndex >= 0 && !_inDragArea) {
|
||||
|
@ -1602,8 +1617,8 @@ void StickersBox::Inner::saveGroupSet() {
|
|||
? _megagroupSetInput.c_inputStickerSetID().vid().v
|
||||
: 0;
|
||||
if (newId != oldId) {
|
||||
_session->api().setGroupStickerSet(_megagroupSet, _megagroupSetInput);
|
||||
_session->api().stickerSetInstalled(Data::Stickers::MegagroupSetId);
|
||||
session().api().setGroupStickerSet(_megagroupSet, _megagroupSetInput);
|
||||
session().api().stickerSetInstalled(Data::Stickers::MegagroupSetId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1733,7 +1748,7 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
|
|||
auto text = _megagroupSetField->getLastText().trimmed();
|
||||
if (text.isEmpty()) {
|
||||
if (_megagroupSelectedSet) {
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
const auto it = sets.find(_megagroupSelectedSet->set->id);
|
||||
if (it != sets.cend() && !it->second->shortName.isEmpty()) {
|
||||
setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
|
||||
|
@ -1744,7 +1759,7 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
|
|||
MTP_inputStickerSetShortName(MTP_string(text))
|
||||
)).done([=](const MTPmessages_StickerSet &result) {
|
||||
_megagroupSetRequestId = 0;
|
||||
auto set = _session->data().stickers().feedSetFull(result);
|
||||
auto set = session().data().stickers().feedSetFull(result);
|
||||
setMegagroupSelectedSet(MTP_inputStickerSetID(
|
||||
MTP_long(set->id),
|
||||
MTP_long(set->access)));
|
||||
|
@ -1771,11 +1786,11 @@ void StickersBox::Inner::rebuildMegagroupSet() {
|
|||
}
|
||||
auto &inputId = _megagroupSetInput.c_inputStickerSetID();
|
||||
auto setId = inputId.vid().v;
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
auto it = sets.find(setId);
|
||||
if (it == sets.cend()
|
||||
|| (it->second->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||
_session->api().scheduleStickerSetRequest(
|
||||
session().api().scheduleStickerSetRequest(
|
||||
inputId.vid().v,
|
||||
inputId.vaccess_hash().v);
|
||||
return;
|
||||
|
@ -1834,22 +1849,22 @@ void StickersBox::Inner::rebuild() {
|
|||
clear();
|
||||
const auto &order = ([&]() -> const StickersSetsOrder & {
|
||||
if (_section == Section::Installed) {
|
||||
auto &result = _session->data().stickers().setsOrder();
|
||||
auto &result = session().data().stickers().setsOrder();
|
||||
if (_megagroupSet && result.empty()) {
|
||||
return _session->data().stickers().featuredSetsOrder();
|
||||
return session().data().stickers().featuredSetsOrder();
|
||||
}
|
||||
return result;
|
||||
} else if (_section == Section::Featured) {
|
||||
return _session->data().stickers().featuredSetsOrder();
|
||||
return session().data().stickers().featuredSetsOrder();
|
||||
}
|
||||
return _session->data().stickers().archivedSetsOrder();
|
||||
return session().data().stickers().archivedSetsOrder();
|
||||
})();
|
||||
_rows.reserve(order.size() + 1);
|
||||
_shiftingStartTimes.reserve(order.size() + 1);
|
||||
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
if (_megagroupSet) {
|
||||
auto usingFeatured = _session->data().stickers().setsOrder().empty();
|
||||
auto usingFeatured = session().data().stickers().setsOrder().empty();
|
||||
_megagroupSubTitle->setText(usingFeatured
|
||||
? tr::lng_stickers_group_from_featured(tr::now)
|
||||
: tr::lng_stickers_group_from_your(tr::now));
|
||||
|
@ -1871,10 +1886,10 @@ void StickersBox::Inner::rebuild() {
|
|||
|
||||
if (set->stickers.isEmpty()
|
||||
|| (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
||||
_session->api().scheduleStickerSetRequest(set->id, set->access);
|
||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
||||
}
|
||||
}
|
||||
_session->api().requestStickerSets();
|
||||
session().api().requestStickerSets();
|
||||
updateSize();
|
||||
}
|
||||
|
||||
|
@ -1899,7 +1914,7 @@ void StickersBox::Inner::updateSize(int newWidth) {
|
|||
|
||||
void StickersBox::Inner::updateRows() {
|
||||
int maxNameWidth = countMaxNameWidth();
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
for (const auto &row : _rows) {
|
||||
const auto it = sets.find(row->set->id);
|
||||
if (it == sets.cend()) {
|
||||
|
@ -2046,18 +2061,18 @@ int StickersBox::Inner::fillSetCount(not_null<StickersSet*> set) const {
|
|||
: set->stickers.size();
|
||||
auto added = 0;
|
||||
if (set->id == Data::Stickers::CloudRecentSetId) {
|
||||
const auto &sets = _session->data().stickers().sets();
|
||||
const auto &sets = session().data().stickers().sets();
|
||||
auto customIt = sets.find(Data::Stickers::CustomSetId);
|
||||
if (customIt != sets.cend()) {
|
||||
added = customIt->second->stickers.size();
|
||||
const auto &recent = _session->data().stickers().getRecentPack();
|
||||
const auto &recent = session().data().stickers().getRecentPack();
|
||||
for (const auto &sticker : recent) {
|
||||
if (customIt->second->stickers.indexOf(sticker.first) < 0) {
|
||||
++added;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
added = _session->data().stickers().getRecentPack().size();
|
||||
added = session().data().stickers().getRecentPack().size();
|
||||
}
|
||||
}
|
||||
return result + added;
|
||||
|
@ -2204,7 +2219,7 @@ void StickersBox::Inner::readVisibleSets() {
|
|||
? (row->stickerMedia && row->stickerMedia->loaded())
|
||||
: true;
|
||||
if (!thumbnailLoading || thumbnailLoaded) {
|
||||
_session->api().readFeaturedSetDelayed(row->set->id);
|
||||
session().api().readFeaturedSetDelayed(row->set->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,10 @@ class CrossButton;
|
|||
class BoxContentDivider;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Main {
|
||||
class Session;
|
||||
} // namespace Main
|
||||
|
@ -56,15 +60,20 @@ public:
|
|||
|
||||
StickersBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Section section);
|
||||
StickersBox(QWidget*, not_null<ChannelData*> megagroup);
|
||||
StickersBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> megagroup);
|
||||
StickersBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
const MTPVector<MTPStickerSetCovered> &attachedSets);
|
||||
~StickersBox();
|
||||
|
||||
[[nodiscard]] Main::Session &session() const;
|
||||
|
||||
void setInnerFocus() override;
|
||||
|
||||
protected:
|
||||
|
@ -123,7 +132,7 @@ private:
|
|||
uint64 offsetId);
|
||||
void showAttachedStickers();
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
MTP::Sender _api;
|
||||
|
||||
object_ptr<Ui::SettingsSlider> _tabs = { nullptr };
|
||||
|
|
|
@ -529,7 +529,7 @@ void StickersListWidget::Footer::mousePressEvent(QMouseEvent *e) {
|
|||
|
||||
if (_iconOver == SpecialOver::Settings) {
|
||||
Ui::show(Box<StickersBox>(
|
||||
&_pan->session(),
|
||||
_pan->controller(),
|
||||
(hasOnlyFeaturedSets()
|
||||
? StickersBox::Section::Featured
|
||||
: StickersBox::Section::Installed)));
|
||||
|
@ -886,9 +886,8 @@ StickersListWidget::StickersListWidget(
|
|||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
_settings->addClickHandler([=] {
|
||||
Ui::show(Box<StickersBox>(
|
||||
&controller->session(),
|
||||
StickersBox::Section::Installed));
|
||||
Ui::show(
|
||||
Box<StickersBox>(controller, StickersBox::Section::Installed));
|
||||
});
|
||||
|
||||
subscribe(session().downloaderTaskFinished(), [=] {
|
||||
|
@ -2107,7 +2106,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
|
|||
removeSet(sets[button->section].id);
|
||||
}
|
||||
} else if (base::get_if<OverGroupAdd>(&pressed)) {
|
||||
Ui::show(Box<StickersBox>(_megagroupSet));
|
||||
Ui::show(Box<StickersBox>(controller(), _megagroupSet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2921,7 +2920,7 @@ void StickersListWidget::displaySet(uint64 setId) {
|
|||
if (_megagroupSet->canEditStickers()) {
|
||||
_displayingSet = true;
|
||||
checkHideWithBox(Ui::show(
|
||||
Box<StickersBox>(_megagroupSet),
|
||||
Box<StickersBox>(controller(), _megagroupSet),
|
||||
Ui::LayerOption::KeepOther).data());
|
||||
return;
|
||||
} else if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) {
|
||||
|
|
|
@ -587,6 +587,10 @@ void InnerWidget::elementShowTooltip(
|
|||
Fn<void()> hiddenCallback) {
|
||||
}
|
||||
|
||||
bool InnerWidget::elementIsGifPaused() {
|
||||
return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
}
|
||||
|
||||
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
||||
memento->setFilter(std::move(_filter));
|
||||
memento->setAdmins(std::move(_admins));
|
||||
|
|
|
@ -111,6 +111,7 @@ public:
|
|||
void elementShowTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback) override;
|
||||
bool elementIsGifPaused() override;
|
||||
|
||||
~InnerWidget();
|
||||
|
||||
|
|
|
@ -1545,6 +1545,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
|
||||
_menu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||
const auto session = &this->session();
|
||||
const auto controller = _controller;
|
||||
|
||||
const auto addItemActions = [&](HistoryItem *item) {
|
||||
if (!item
|
||||
|
@ -1584,7 +1585,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
});
|
||||
if (photo->hasSticker) {
|
||||
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
|
||||
session->api().requestAttachedStickerSets(photo);
|
||||
controller->requestAttachedStickerSets(photo);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -2524,6 +2525,10 @@ void HistoryInner::elementShowTooltip(
|
|||
_widget->showInfoTooltip(text, std::move(hiddenCallback));
|
||||
}
|
||||
|
||||
bool HistoryInner::elementIsGifPaused() {
|
||||
return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
}
|
||||
|
||||
auto HistoryInner::getSelectionState() const
|
||||
-> HistoryView::TopBarWidget::SelectedState {
|
||||
auto result = HistoryView::TopBarWidget::SelectedState {};
|
||||
|
@ -3386,6 +3391,9 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
|
|||
Instance->elementShowTooltip(text, hiddenCallback);
|
||||
}
|
||||
}
|
||||
bool elementIsGifPaused() override {
|
||||
return Instance ? Instance->elementIsGifPaused() : false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ public:
|
|||
void elementShowTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback);
|
||||
bool elementIsGifPaused();
|
||||
|
||||
void updateBotInfo(bool recount = true);
|
||||
|
||||
|
|
|
@ -855,6 +855,7 @@ void HistoryWidget::supportShareContact(Support::Contact contact) {
|
|||
action);
|
||||
};
|
||||
const auto box = Ui::show(Box<Support::ConfirmContactBox>(
|
||||
controller(),
|
||||
_history,
|
||||
contact,
|
||||
crl::guard(this, submit)));
|
||||
|
@ -1868,7 +1869,7 @@ void HistoryWidget::showHistory(
|
|||
_channel = peerToChannel(_peer->id);
|
||||
_canSendMessages = _peer->canWrite();
|
||||
_contactStatus = std::make_unique<HistoryView::ContactStatus>(
|
||||
&controller()->window(),
|
||||
controller(),
|
||||
this,
|
||||
_peer);
|
||||
_contactStatus->heightValue() | rpl::start_with_next([=] {
|
||||
|
|
|
@ -178,10 +178,10 @@ void ContactStatus::Bar::updateButtonsGeometry() {
|
|||
}
|
||||
|
||||
ContactStatus::ContactStatus(
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer)
|
||||
: _window(window)
|
||||
: _controller(window)
|
||||
, _bar(parent, object_ptr<Bar>(parent, peer->shortName()))
|
||||
, _shadow(parent) {
|
||||
setupWidgets(parent);
|
||||
|
@ -294,15 +294,15 @@ void ContactStatus::setupHandlers(not_null<PeerData*> peer) {
|
|||
void ContactStatus::setupAddHandler(not_null<UserData*> user) {
|
||||
_bar.entity()->addClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
_window->show(Box(EditContactBox, _window, user));
|
||||
_controller->window().show(Box(EditContactBox, _controller, user));
|
||||
}, _bar.lifetime());
|
||||
}
|
||||
|
||||
void ContactStatus::setupBlockHandler(not_null<UserData*> user) {
|
||||
_bar.entity()->blockClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
_window->show(
|
||||
Box(Window::PeerMenuBlockUserBox, _window, user, true));
|
||||
_controller->window().show(
|
||||
Box(Window::PeerMenuBlockUserBox, &_controller->window(), user, true));
|
||||
}, _bar.lifetime());
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
|
|||
(*box)->closeBox();
|
||||
}
|
||||
};
|
||||
*box = _window->show(Box<ConfirmBox>(
|
||||
*box = _controller->window().show(Box<ConfirmBox>(
|
||||
tr::lng_new_contact_share_sure(
|
||||
tr::now,
|
||||
lt_phone,
|
||||
|
@ -365,7 +365,7 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
|
|||
Ui::Toast::Show(tr::lng_report_spam_done(tr::now));
|
||||
|
||||
// Destroys _bar.
|
||||
_window->sessionController()->showBackFromStack();
|
||||
_controller->showBackFromStack();
|
||||
});
|
||||
if (const auto user = peer->asUser()) {
|
||||
peer->session().api().blockUser(user);
|
||||
|
@ -373,7 +373,7 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
|
|||
const auto text = ((peer->isChat() || peer->isMegagroup())
|
||||
? tr::lng_report_spam_sure_group
|
||||
: tr::lng_report_spam_sure_channel)(tr::now);
|
||||
_window->show(Box<ConfirmBox>(
|
||||
_controller->window().show(Box<ConfirmBox>(
|
||||
text,
|
||||
tr::lng_report_spam_ok(tr::now),
|
||||
st::attentionBoxButton,
|
||||
|
|
|
@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/shadow.h"
|
||||
|
||||
namespace Window {
|
||||
class Controller;
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
|
@ -25,7 +25,7 @@ namespace HistoryView {
|
|||
class ContactStatus final {
|
||||
public:
|
||||
ContactStatus(
|
||||
not_null<Window::Controller*> window,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
|
@ -87,7 +87,7 @@ private:
|
|||
|
||||
static rpl::producer<State> PeerState(not_null<PeerData*> peer);
|
||||
|
||||
not_null<Window::Controller*> _window;
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
State _state = State::None;
|
||||
Ui::SlideWrap<Bar> _bar;
|
||||
Ui::PlainShadow _shadow;
|
||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/core_settings.h"
|
||||
#include "main/main_session.h"
|
||||
#include "chat_helpers/stickers_emoji_pack.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_groups.h"
|
||||
#include "data/data_media_types.h"
|
||||
|
@ -55,6 +56,10 @@ bool IsAttachedToPreviousInSavedMessages(
|
|||
|
||||
} // namespace
|
||||
|
||||
SimpleElementDelegate::SimpleElementDelegate(
|
||||
not_null<Window::SessionController*> controller)
|
||||
: _controller(controller) {
|
||||
}
|
||||
|
||||
std::unique_ptr<HistoryView::Element> SimpleElementDelegate::elementCreate(
|
||||
not_null<HistoryMessage*> message,
|
||||
|
@ -103,6 +108,10 @@ void SimpleElementDelegate::elementShowTooltip(
|
|||
Fn<void()> hiddenCallback) {
|
||||
}
|
||||
|
||||
bool SimpleElementDelegate::elementIsGifPaused() {
|
||||
return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
}
|
||||
|
||||
TextSelection UnshiftItemSelection(
|
||||
TextSelection selection,
|
||||
uint16 byLength) {
|
||||
|
|
|
@ -17,6 +17,10 @@ class HistoryItem;
|
|||
class HistoryMessage;
|
||||
class HistoryService;
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace HistoryView {
|
||||
|
||||
enum class PointState : char;
|
||||
|
@ -57,11 +61,15 @@ public:
|
|||
virtual void elementShowTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback) = 0;
|
||||
virtual bool elementIsGifPaused() = 0;
|
||||
|
||||
};
|
||||
|
||||
class SimpleElementDelegate : public ElementDelegate {
|
||||
public:
|
||||
explicit SimpleElementDelegate(
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
std::unique_ptr<Element> elementCreate(
|
||||
not_null<HistoryMessage*> message,
|
||||
Element *replacing = nullptr) override;
|
||||
|
@ -83,6 +91,10 @@ public:
|
|||
void elementShowTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback) override;
|
||||
bool elementIsGifPaused() override;
|
||||
|
||||
private:
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1165,6 +1165,10 @@ void ListWidget::elementShowTooltip(
|
|||
Fn<void()> hiddenCallback) {
|
||||
}
|
||||
|
||||
bool ListWidget::elementIsGifPaused() {
|
||||
return _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
}
|
||||
|
||||
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
||||
memento->setAroundPosition(_aroundPosition);
|
||||
auto state = countScrollState();
|
||||
|
|
|
@ -204,6 +204,7 @@ public:
|
|||
void elementShowTooltip(
|
||||
const TextWithEntities &text,
|
||||
Fn<void()> hiddenCallback) override;
|
||||
bool elementIsGifPaused() override;
|
||||
|
||||
~ListWidget();
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
|
|||
const auto loaded = dataLoaded();
|
||||
const auto displayLoading = item->isSending() || _data->displayLoading();
|
||||
const auto selected = (selection == FullSelection);
|
||||
const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
const auto autoPaused = _parent->delegate()->elementIsGifPaused();
|
||||
const auto cornerDownload = downloadInCorner();
|
||||
const auto canBePlayed = _dataMedia->canBePlayed();
|
||||
const auto autoplay = autoplayEnabled()
|
||||
|
@ -902,7 +902,7 @@ void Gif::drawGrouped(
|
|||
const auto loaded = dataLoaded();
|
||||
const auto displayLoading = (item->id < 0) || _data->displayLoading();
|
||||
const auto selected = (selection == FullSelection);
|
||||
const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
const auto autoPaused = _parent->delegate()->elementIsGifPaused();
|
||||
const auto fullFeatured = fullFeaturedGrouped(sides);
|
||||
const auto cornerDownload = fullFeatured && downloadInCorner();
|
||||
const auto canBePlayed = _dataMedia->canBePlayed();
|
||||
|
@ -1465,8 +1465,7 @@ void Gif::repaintStreamedContent() {
|
|||
if (own && !own->frozenFrame.isNull()) {
|
||||
return;
|
||||
}
|
||||
if (App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any)
|
||||
&& !activeRoundStreamed()) {
|
||||
if (_parent->delegate()->elementIsGifPaused() && !activeRoundStreamed()) {
|
||||
return;
|
||||
}
|
||||
history()->owner().requestViewRepaint(_parent);
|
||||
|
|
|
@ -185,7 +185,7 @@ void Sticker::paintLottie(Painter &p, const QRect &r, bool selected) {
|
|||
return;
|
||||
}
|
||||
|
||||
const auto paused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
const auto paused = _parent->delegate()->elementIsGifPaused();
|
||||
const auto playOnce = (_diceIndex > 0)
|
||||
? true
|
||||
: (_diceIndex == 0)
|
||||
|
|
|
@ -277,12 +277,12 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
UsernameValue(user),
|
||||
tr::lng_context_copy_mention(tr::now));
|
||||
|
||||
const auto window = &_controller->parentController()->window();
|
||||
const auto controller = _controller->parentController();
|
||||
AddMainButton(
|
||||
result,
|
||||
tr::lng_info_add_as_contact(),
|
||||
CanAddContactValue(user),
|
||||
[=] { window->show(Box(EditContactBox, window, user)); },
|
||||
[=] { controller->window().show(Box(EditContactBox, controller, user)); },
|
||||
tracker);
|
||||
} else {
|
||||
auto linkText = LinkValue(
|
||||
|
@ -507,12 +507,12 @@ void ActionsFiller::addShareContactAction(not_null<UserData*> user) {
|
|||
}
|
||||
|
||||
void ActionsFiller::addEditContactAction(not_null<UserData*> user) {
|
||||
const auto window = &_controller->parentController()->window();
|
||||
const auto controller = _controller->parentController();
|
||||
AddActionButton(
|
||||
_wrap,
|
||||
tr::lng_info_edit_contact(),
|
||||
IsContactValue(user),
|
||||
[=] { window->show(Box(EditContactBox, window, user)); });
|
||||
[=] { controller->window().show(Box(EditContactBox, controller, user)); });
|
||||
}
|
||||
|
||||
void ActionsFiller::addDeleteContactAction(
|
||||
|
|
|
@ -1523,8 +1523,12 @@ void OverlayWidget::onAttachedStickers() {
|
|||
if (!session) {
|
||||
return;
|
||||
}
|
||||
const auto &active = _session->windows();
|
||||
if (active.empty()) {
|
||||
return;
|
||||
}
|
||||
close();
|
||||
session->api().requestAttachedStickerSets(_photo);
|
||||
active.front()->requestAttachedStickerSets(_photo);
|
||||
}
|
||||
|
||||
auto OverlayWidget::sharedMediaType() const
|
||||
|
|
|
@ -722,7 +722,8 @@ void SetupStickersEmoji(
|
|||
&st::settingsIconStickers,
|
||||
st::settingsChatIconLeft
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<StickersBox>(session, StickersBox::Section::Installed));
|
||||
Ui::show(
|
||||
Box<StickersBox>(controller, StickersBox::Section::Installed));
|
||||
});
|
||||
|
||||
AddButton(
|
||||
|
|
|
@ -689,7 +689,8 @@ rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionsDescription()
|
|||
|
||||
ForwardsPrivacyController::ForwardsPrivacyController(
|
||||
not_null<Window::SessionController*> controller)
|
||||
: _controller(controller) {
|
||||
: SimpleElementDelegate(controller)
|
||||
, _controller(controller) {
|
||||
}
|
||||
|
||||
ApiWrap::Privacy::Key ForwardsPrivacyController::key() {
|
||||
|
|
|
@ -504,10 +504,12 @@ void Autocomplete::submitValue(const QString &value) {
|
|||
|
||||
ConfirmContactBox::ConfirmContactBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<History*> history,
|
||||
const Contact &data,
|
||||
Fn<void(Qt::KeyboardModifiers)> submit)
|
||||
: _comment(GenerateCommentItem(this, history, data))
|
||||
: SimpleElementDelegate(controller)
|
||||
, _comment(GenerateCommentItem(this, history, data))
|
||||
, _contact(GenerateContactItem(this, history, data))
|
||||
, _submit(submit) {
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ namespace Main {
|
|||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Ui {
|
||||
class ScrollArea;
|
||||
class InputField;
|
||||
|
@ -65,6 +69,7 @@ class ConfirmContactBox
|
|||
public:
|
||||
ConfirmContactBox(
|
||||
QWidget*,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<History*> history,
|
||||
const Contact &data,
|
||||
Fn<void(Qt::KeyboardModifiers)> submit);
|
||||
|
|
|
@ -827,12 +827,12 @@ void MainMenu::refreshMenu() {
|
|||
}, &st::mainMenuContacts, &st::mainMenuContactsOver);
|
||||
if (_controller->session().serverConfig().phoneCallsEnabled.current()) {
|
||||
_menu->addAction(tr::lng_menu_calls(tr::now), [=] {
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(controller), [](not_null<PeerListBox*> box) {
|
||||
Ui::show(Box<PeerListBox>(std::make_unique<Calls::BoxController>(controller), [=](not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_close(), [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
box->addTopButton(st::callSettingsButton, [=] {
|
||||
App::wnd()->sessionController()->showSettings(
|
||||
controller->showSettings(
|
||||
Settings::Type::Calls,
|
||||
Window::SectionShow(anim::type::instant));
|
||||
});
|
||||
|
|
|
@ -462,7 +462,7 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
|||
if (!user->isContact() && !user->isSelf() && !user->isBot()) {
|
||||
_addAction(
|
||||
tr::lng_info_add_as_contact(tr::now),
|
||||
[=] { window->show(Box(EditContactBox, window, user)); });
|
||||
[=] { window->show(Box(EditContactBox, controller, user)); });
|
||||
}
|
||||
if (user->canShareThisContact()) {
|
||||
_addAction(
|
||||
|
@ -472,7 +472,7 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
|||
if (user->isContact() && !user->isSelf()) {
|
||||
_addAction(
|
||||
tr::lng_info_edit_contact(tr::now),
|
||||
[=] { window->show(Box(EditContactBox, window, user)); });
|
||||
[=] { window->show(Box(EditContactBox, controller, user)); });
|
||||
_addAction(
|
||||
tr::lng_info_delete_contact(tr::now),
|
||||
[=] { PeerMenuDeleteContact(user); });
|
||||
|
|
|
@ -23,11 +23,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_photo.h" // requestAttachedStickerSets.
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "boxes/sticker_set_box.h" // requestAttachedStickerSets.
|
||||
#include "boxes/confirm_box.h" // requestAttachedStickerSets.
|
||||
#include "boxes/stickers_box.h" // requestAttachedStickerSets.
|
||||
#include "lang/lang_keys.h" // requestAttachedStickerSets.
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_session.h"
|
||||
|
@ -223,6 +228,36 @@ rpl::producer<> SessionController::filtersMenuChanged() const {
|
|||
return _filtersMenuChanged.events();
|
||||
}
|
||||
|
||||
void SessionController::requestAttachedStickerSets(
|
||||
not_null<PhotoData*> photo) {
|
||||
session().api().request(_attachedStickerSetsRequestId).cancel();
|
||||
_attachedStickerSetsRequestId = session().api().request(
|
||||
MTPmessages_GetAttachedStickers(
|
||||
MTP_inputStickeredMediaPhoto(photo->mtpInput())
|
||||
)).done([=](const MTPVector<MTPStickerSetCovered> &result) {
|
||||
if (result.v.isEmpty()) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
return;
|
||||
} else if (result.v.size() > 1) {
|
||||
Ui::show(Box<StickersBox>(this, result));
|
||||
return;
|
||||
}
|
||||
// Single attached sticker pack.
|
||||
const auto setData = result.v.front().match([&](const auto &data) {
|
||||
return data.vset().match([&](const MTPDstickerSet &data) {
|
||||
return &data;
|
||||
});
|
||||
});
|
||||
|
||||
const auto setId = (setData->vid().v && setData->vaccess_hash().v)
|
||||
? MTP_inputStickerSetID(setData->vid(), setData->vaccess_hash())
|
||||
: MTP_inputStickerSetShortName(setData->vshort_name());
|
||||
Ui::show(Box<StickerSetBox>(this, setId), Ui::LayerOption::KeepOther);
|
||||
}).fail([=](const RPCError &error) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
}).send();
|
||||
}
|
||||
|
||||
void SessionController::checkOpenedFilter() {
|
||||
if (const auto filterId = activeChatsFilterCurrent()) {
|
||||
const auto &list = session().data().chatsFilters().list();
|
||||
|
@ -800,6 +835,8 @@ void SessionController::setActiveChatsFilter(FilterId id) {
|
|||
}
|
||||
}
|
||||
|
||||
SessionController::~SessionController() = default;
|
||||
SessionController::~SessionController() {
|
||||
session().api().request(_attachedStickerSetsRequestId).cancel();
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "dialogs/dialogs_key.h"
|
||||
#include "ui/effects/animation_value.h"
|
||||
|
||||
class PhotoData;
|
||||
class MainWidget;
|
||||
class MainWindow;
|
||||
class HistoryMessage;
|
||||
|
@ -304,6 +305,8 @@ public:
|
|||
void toggleFiltersMenu(bool enabled);
|
||||
[[nodiscard]] rpl::producer<> filtersMenuChanged() const;
|
||||
|
||||
void requestAttachedStickerSets(not_null<PhotoData*> photo);
|
||||
|
||||
rpl::lifetime &lifetime() {
|
||||
return _lifetime;
|
||||
}
|
||||
|
@ -361,6 +364,8 @@ private:
|
|||
|
||||
rpl::event_stream<> _filtersMenuChanged;
|
||||
|
||||
mtpRequestId _attachedStickerSetsRequestId = 0;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue