mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Remove some calls to Auth().
This commit is contained in:
parent
9cf4cf6dca
commit
06982fdf04
39 changed files with 573 additions and 444 deletions
|
@ -3270,7 +3270,7 @@ void ApiWrap::toggleSavedGif(
|
|||
)).done([=](const MTPBool &result) {
|
||||
if (mtpIsTrue(result)) {
|
||||
if (saved) {
|
||||
App::addSavedGif(document);
|
||||
session().data().addSavedGif(document);
|
||||
}
|
||||
}
|
||||
}).fail([=](const RPCError &error) {
|
||||
|
|
|
@ -115,33 +115,6 @@ namespace App {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void addSavedGif(DocumentData *doc) {
|
||||
auto &saved = Auth().data().savedGifsRef();
|
||||
int32 index = saved.indexOf(doc);
|
||||
if (index) {
|
||||
if (index > 0) saved.remove(index);
|
||||
saved.push_front(doc);
|
||||
if (saved.size() > Global::SavedGifsLimit()) saved.pop_back();
|
||||
Local::writeSavedGifs();
|
||||
|
||||
Auth().data().notifySavedGifsUpdated();
|
||||
Auth().data().setLastSavedGifsUpdate(0);
|
||||
Auth().api().updateStickers();
|
||||
}
|
||||
}
|
||||
|
||||
void checkSavedGif(HistoryItem *item) {
|
||||
if (!item->Has<HistoryMessageForwarded>() && (item->out() || item->history()->peer == Auth().user())) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
if (document->isGifv()) {
|
||||
addSavedGif(document);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString peerName(const PeerData *peer, bool forDialogs) {
|
||||
return peer ? ((forDialogs && peer->isUser() && !peer->asUser()->nameOrPhone.isEmpty()) ? peer->asUser()->nameOrPhone : peer->name) : tr::lng_deleted(tr::now);
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@ namespace App {
|
|||
|
||||
QString formatPhone(QString phone);
|
||||
|
||||
void addSavedGif(DocumentData *doc);
|
||||
void checkSavedGif(HistoryItem *item);
|
||||
[[nodiscard]] QString peerName(const PeerData *peer, bool forDialogs = false);
|
||||
|
||||
void hoveredItem(HistoryView::Element *item);
|
||||
|
|
|
@ -154,7 +154,10 @@ void ShowAddParticipantsError(
|
|||
|
||||
class RevokePublicLinkBox::Inner : public TWidget, private MTP::Sender {
|
||||
public:
|
||||
Inner(QWidget *parent, Fn<void()> revokeCallback);
|
||||
Inner(
|
||||
QWidget *parent,
|
||||
not_null<AuthSession*> session,
|
||||
Fn<void()> revokeCallback);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
@ -173,6 +176,8 @@ private:
|
|||
void paintChat(Painter &p, const ChatRow &row, bool selected) const;
|
||||
void updateSelected();
|
||||
|
||||
const not_null<AuthSession*> _session;
|
||||
|
||||
PeerData *_selected = nullptr;
|
||||
PeerData *_pressed = nullptr;
|
||||
|
||||
|
@ -188,8 +193,20 @@ private:
|
|||
|
||||
};
|
||||
|
||||
AddContactBox::AddContactBox(QWidget*, QString fname, QString lname, QString phone)
|
||||
: _first(this, st::defaultInputField, tr::lng_signup_firstname(), fname)
|
||||
AddContactBox::AddContactBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session)
|
||||
: AddContactBox(nullptr, session, QString(), QString(), QString()) {
|
||||
}
|
||||
|
||||
AddContactBox::AddContactBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
QString fname,
|
||||
QString lname,
|
||||
QString phone)
|
||||
: _session(session)
|
||||
, _first(this, st::defaultInputField, tr::lng_signup_firstname(), fname)
|
||||
, _last(this, st::defaultInputField, tr::lng_signup_lastname(), lname)
|
||||
, _phone(this, st::defaultInputField, tr::lng_contact_phone(), phone)
|
||||
, _invertOrder(langFirstNameGoesSecond()) {
|
||||
|
@ -198,28 +215,15 @@ AddContactBox::AddContactBox(QWidget*, QString fname, QString lname, QString pho
|
|||
}
|
||||
}
|
||||
|
||||
AddContactBox::AddContactBox(QWidget*, UserData *user)
|
||||
: _user(user)
|
||||
, _first(this, st::defaultInputField, tr::lng_signup_firstname(), user->firstName)
|
||||
, _last(this, st::defaultInputField, tr::lng_signup_lastname(), user->lastName)
|
||||
, _phone(this, st::defaultInputField, tr::lng_contact_phone(), user->phone())
|
||||
, _invertOrder(langFirstNameGoesSecond()) {
|
||||
_phone->setDisabled(true);
|
||||
}
|
||||
|
||||
void AddContactBox::prepare() {
|
||||
if (_invertOrder) {
|
||||
setTabOrder(_last, _first);
|
||||
}
|
||||
if (_user) {
|
||||
setTitle(tr::lng_edit_contact_title());
|
||||
} else {
|
||||
const auto readyToAdd = !_phone->getLastText().isEmpty()
|
||||
&& (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty());
|
||||
setTitle(readyToAdd
|
||||
? tr::lng_confirm_contact_data()
|
||||
: tr::lng_enter_contact_data());
|
||||
}
|
||||
const auto readyToAdd = !_phone->getLastText().isEmpty()
|
||||
&& (!_first->getLastText().isEmpty() || !_last->getLastText().isEmpty());
|
||||
setTitle(readyToAdd
|
||||
? tr::lng_confirm_contact_data()
|
||||
: tr::lng_enter_contact_data());
|
||||
updateButtons();
|
||||
|
||||
connect(_first, &Ui::InputField::submitted, [=] { submit(); });
|
||||
|
@ -307,7 +311,7 @@ void AddContactBox::save() {
|
|||
_first->showError();
|
||||
}
|
||||
return;
|
||||
} else if (!_user && !IsValidPhone(phone)) {
|
||||
} else if (!IsValidPhone(phone)) {
|
||||
_phone->setFocus();
|
||||
_phone->showError();
|
||||
return;
|
||||
|
@ -317,49 +321,31 @@ void AddContactBox::save() {
|
|||
lastName = QString();
|
||||
}
|
||||
_sentName = firstName;
|
||||
if (_user) {
|
||||
_contactId = rand_value<uint64>();
|
||||
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(_user->phone()), MTP_string(firstName), MTP_string(lastName)));
|
||||
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v)), rpcDone(&AddContactBox::onSaveUserDone), rpcFail(&AddContactBox::onSaveUserFail));
|
||||
} else {
|
||||
_contactId = rand_value<uint64>();
|
||||
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(phone), MTP_string(firstName), MTP_string(lastName)));
|
||||
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v)), rpcDone(&AddContactBox::onImportDone));
|
||||
}
|
||||
_contactId = rand_value<uint64>();
|
||||
_addRequest = _session->api().request(MTPcontacts_ImportContacts(
|
||||
MTP_vector<MTPInputContact>(
|
||||
1,
|
||||
MTP_inputPhoneContact(
|
||||
MTP_long(_contactId),
|
||||
MTP_string(phone),
|
||||
MTP_string(firstName),
|
||||
MTP_string(lastName)))
|
||||
)).done(crl::guard(this, [=](const MTPcontacts_ImportedContacts &res) {
|
||||
})).send();
|
||||
}
|
||||
|
||||
bool AddContactBox::onSaveUserFail(const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
_addRequest = 0;
|
||||
const auto &err = error.type();
|
||||
const auto firstName = _first->getLastText().trimmed();
|
||||
const auto lastName = _last->getLastText().trimmed();
|
||||
if (err == "CHAT_TITLE_NOT_MODIFIED") {
|
||||
_user->setName(firstName, lastName, _user->nameOrPhone, _user->username);
|
||||
closeBox();
|
||||
return true;
|
||||
} else if (err == "NO_CHAT_TITLE") {
|
||||
_first->setFocus();
|
||||
_first->showError();
|
||||
return true;
|
||||
}
|
||||
_first->setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
|
||||
void AddContactBox::importDone(const MTPcontacts_ImportedContacts &result) {
|
||||
if (!isBoxShown() || !App::main()) return;
|
||||
|
||||
const auto &d = res.c_contacts_importedContacts();
|
||||
Auth().data().processUsers(d.vusers());
|
||||
const auto &d = result.c_contacts_importedContacts();
|
||||
_session->data().processUsers(d.vusers());
|
||||
|
||||
const auto &v = d.vimported().v;
|
||||
const auto user = [&]() -> UserData* {
|
||||
if (!v.isEmpty()) {
|
||||
auto &c = v.front().c_importedContact();
|
||||
if (c.vclient_id().v == _contactId) {
|
||||
return Auth().data().userLoaded(c.vuser_id().v);
|
||||
return _session->data().userLoaded(c.vuser_id().v);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -377,12 +363,6 @@ void AddContactBox::onImportDone(const MTPcontacts_ImportedContacts &res) {
|
|||
}
|
||||
}
|
||||
|
||||
void AddContactBox::onSaveUserDone(const MTPcontacts_ImportedContacts &res) {
|
||||
auto &d = res.c_contacts_importedContacts();
|
||||
Auth().data().processUsers(d.vusers());
|
||||
closeBox();
|
||||
}
|
||||
|
||||
void AddContactBox::retry() {
|
||||
_addRequest = 0;
|
||||
_contactId = 0;
|
||||
|
@ -402,19 +382,19 @@ void AddContactBox::updateButtons() {
|
|||
if (_retrying) {
|
||||
addButton(tr::lng_try_other_contact(), [=] { retry(); });
|
||||
} else {
|
||||
addButton(
|
||||
_user ? tr::lng_settings_save() : tr::lng_add_contact(),
|
||||
[=] { save(); });
|
||||
addButton(tr::lng_add_contact(), [=] { save(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
}
|
||||
}
|
||||
|
||||
GroupInfoBox::GroupInfoBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
Type type,
|
||||
const QString &title,
|
||||
Fn<void(not_null<ChannelData*>)> channelDone)
|
||||
: _type(type)
|
||||
: _session(session)
|
||||
, _type(type)
|
||||
, _initialTitle(title)
|
||||
, _channelDone(std::move(channelDone)) {
|
||||
}
|
||||
|
@ -537,7 +517,7 @@ void GroupInfoBox::createGroup(
|
|||
auto image = _photo->takeResultImage();
|
||||
Ui::hideLayer();
|
||||
|
||||
Auth().api().applyUpdates(result);
|
||||
_session->api().applyUpdates(result);
|
||||
|
||||
auto success = base::make_optional(&result)
|
||||
| [](auto updates) -> std::optional<const QVector<MTPChat>*> {
|
||||
|
@ -557,8 +537,8 @@ void GroupInfoBox::createGroup(
|
|||
? base::make_optional(chats)
|
||||
: std::nullopt;
|
||||
}
|
||||
| [](auto chats) {
|
||||
return Auth().data().chat(chats->front().c_chat().vid().v);
|
||||
| [&](auto chats) {
|
||||
return _session->data().chat(chats->front().c_chat().vid().v);
|
||||
}
|
||||
| [&](not_null<ChatData*> chat) {
|
||||
if (!image.isNull()) {
|
||||
|
@ -646,7 +626,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
|
|||
MTPInputGeoPoint(), // geo_point
|
||||
MTPstring() // address
|
||||
)).done([=](const MTPUpdates &result) {
|
||||
Auth().api().applyUpdates(result);
|
||||
_session->api().applyUpdates(result);
|
||||
|
||||
const auto success = base::make_optional(&result)
|
||||
| [](auto updates) -> std::optional<const QVector<MTPChat>*> {
|
||||
|
@ -664,8 +644,8 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
|
|||
? base::make_optional(chats)
|
||||
: std::nullopt;
|
||||
}
|
||||
| [](auto chats) {
|
||||
return Auth().data().channel(chats->front().c_channel().vid().v);
|
||||
| [&](auto chats) {
|
||||
return _session->data().channel(chats->front().c_channel().vid().v);
|
||||
}
|
||||
| [&](not_null<ChannelData*> channel) {
|
||||
auto image = _photo->takeResultImage();
|
||||
|
@ -729,10 +709,14 @@ void GroupInfoBox::updateMaxHeight() {
|
|||
setDimensions(st::boxWideWidth, newHeight);
|
||||
}
|
||||
|
||||
SetupChannelBox::SetupChannelBox(QWidget*, ChannelData *channel, bool existing)
|
||||
SetupChannelBox::SetupChannelBox(
|
||||
QWidget*,
|
||||
not_null<ChannelData*> channel,
|
||||
bool existing)
|
||||
: _channel(channel)
|
||||
, _existing(existing)
|
||||
, _privacyGroup(std::make_shared<Ui::RadioenumGroup<Privacy>>(Privacy::Public))
|
||||
, _privacyGroup(
|
||||
std::make_shared<Ui::RadioenumGroup<Privacy>>(Privacy::Public))
|
||||
, _public(
|
||||
this,
|
||||
_privacyGroup,
|
||||
|
@ -749,7 +733,12 @@ SetupChannelBox::SetupChannelBox(QWidget*, ChannelData *channel, bool existing)
|
|||
? tr::lng_create_private_group_title
|
||||
: tr::lng_create_private_channel_title)(tr::now),
|
||||
st::defaultBoxCheckbox)
|
||||
, _aboutPublicWidth(st::boxWideWidth - st::boxPadding.left() - st::boxButtonPadding.right() - st::newGroupPadding.left() - st::defaultRadio.diameter - st::defaultBoxCheckbox.textPosition.x())
|
||||
, _aboutPublicWidth(st::boxWideWidth
|
||||
- st::boxPadding.left()
|
||||
- st::boxButtonPadding.right()
|
||||
- st::newGroupPadding.left()
|
||||
- st::defaultRadio.diameter
|
||||
- st::defaultBoxCheckbox.textPosition.x())
|
||||
, _aboutPublic(
|
||||
st::defaultTextStyle,
|
||||
(channel->isMegagroup()
|
||||
|
@ -1003,11 +992,16 @@ void SetupChannelBox::privacyChanged(Privacy value) {
|
|||
if (value == Privacy::Public) {
|
||||
if (_tooMuchUsernames) {
|
||||
_privacyGroup->setValue(Privacy::Private);
|
||||
Ui::show(Box<RevokePublicLinkBox>(crl::guard(this, [this] {
|
||||
const auto callback = crl::guard(this, [=] {
|
||||
_tooMuchUsernames = false;
|
||||
_privacyGroup->setValue(Privacy::Public);
|
||||
check();
|
||||
})), LayerOption::KeepOther);
|
||||
});
|
||||
Ui::show(
|
||||
Box<RevokePublicLinkBox>(
|
||||
&_channel->session(),
|
||||
callback),
|
||||
LayerOption::KeepOther);
|
||||
return;
|
||||
}
|
||||
_link->show();
|
||||
|
@ -1096,23 +1090,30 @@ bool SetupChannelBox::onCheckFail(const RPCError &error) {
|
|||
}
|
||||
|
||||
void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
|
||||
closeBox();
|
||||
Ui::show(Box<RevokePublicLinkBox>([channel = _channel, existing = _existing]() {
|
||||
const auto channel = _channel;
|
||||
const auto existing = _existing;
|
||||
const auto callback = [=] {
|
||||
Ui::show(
|
||||
Box<SetupChannelBox>(channel, existing),
|
||||
LayerOption::KeepOther);
|
||||
}), LayerOption::KeepOther);
|
||||
};
|
||||
closeBox();
|
||||
Ui::show(
|
||||
Box<RevokePublicLinkBox>(
|
||||
&channel->session(),
|
||||
callback),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
bool SetupChannelBox::onFirstCheckFail(const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
_checkRequestId = 0;
|
||||
QString err(error.type());
|
||||
if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
|
||||
const auto &type = error.type();
|
||||
if (type == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
|
||||
Ui::hideLayer();
|
||||
return true;
|
||||
} else if (err == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
|
||||
} else if (type == qstr("CHANNELS_ADMIN_PUBLIC_TOO_MUCH")) {
|
||||
if (_existing) {
|
||||
showRevokePublicLinkBoxForEdit();
|
||||
} else {
|
||||
|
@ -1248,7 +1249,12 @@ bool EditNameBox::saveSelfFail(const RPCError &error) {
|
|||
return true;
|
||||
}
|
||||
|
||||
RevokePublicLinkBox::Inner::Inner(QWidget *parent, Fn<void()> revokeCallback) : TWidget(parent)
|
||||
RevokePublicLinkBox::Inner::Inner(
|
||||
QWidget *parent,
|
||||
not_null<AuthSession*> session,
|
||||
Fn<void()> revokeCallback)
|
||||
: TWidget(parent)
|
||||
, _session(session)
|
||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||
, _revokeWidth(st::normalFont->width(tr::lng_channels_too_much_public_revoke(tr::now)))
|
||||
, _revokeCallback(std::move(revokeCallback)) {
|
||||
|
@ -1263,7 +1269,7 @@ RevokePublicLinkBox::Inner::Inner(QWidget *parent, Fn<void()> revokeCallback) :
|
|||
return data.vchats().v;
|
||||
});
|
||||
for (const auto &chat : chats) {
|
||||
if (const auto peer = Auth().data().processChat(chat)) {
|
||||
if (const auto peer = _session->data().processChat(chat)) {
|
||||
if (!peer->isChannel() || peer->userName().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1289,8 +1295,10 @@ RevokePublicLinkBox::Inner::Inner(QWidget *parent, Fn<void()> revokeCallback) :
|
|||
|
||||
RevokePublicLinkBox::RevokePublicLinkBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
Fn<void()> revokeCallback)
|
||||
: _aboutRevoke(
|
||||
: _session(session)
|
||||
, _aboutRevoke(
|
||||
this,
|
||||
tr::lng_channels_too_much_public_about(tr::now),
|
||||
st::aboutRevokePublicLabel)
|
||||
|
@ -1299,7 +1307,7 @@ RevokePublicLinkBox::RevokePublicLinkBox(
|
|||
|
||||
void RevokePublicLinkBox::prepare() {
|
||||
_innerTop = st::boxPadding.top() + _aboutRevoke->height() + st::boxPadding.top();
|
||||
_inner = setInnerWidget(object_ptr<Inner>(this, [=] {
|
||||
_inner = setInnerWidget(object_ptr<Inner>(this, _session, [=] {
|
||||
const auto callback = _revokeCallback;
|
||||
closeBox();
|
||||
if (callback) {
|
||||
|
@ -1309,7 +1317,7 @@ void RevokePublicLinkBox::prepare() {
|
|||
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
subscribe(Auth().downloaderTaskFinished(), [=] { update(); });
|
||||
subscribe(_session->downloaderTaskFinished(), [=] { update(); });
|
||||
|
||||
_inner->resizeToWidth(st::boxWideWidth);
|
||||
setDimensions(st::boxWideWidth, _innerTop + _inner->height());
|
||||
|
@ -1323,7 +1331,7 @@ void RevokePublicLinkBox::Inner::updateSelected() {
|
|||
auto point = mapFromGlobal(QCursor::pos());
|
||||
PeerData *selected = nullptr;
|
||||
auto top = _rowsTop;
|
||||
for_const (auto &row, _rows) {
|
||||
for (const auto &row : _rows) {
|
||||
auto revokeLink = rtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - _revokeWidth, top + st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, _revokeWidth, st::normalFont->height, width());
|
||||
if (revokeLink.contains(point)) {
|
||||
selected = row.peer;
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
class ConfirmBox;
|
||||
class PeerListBox;
|
||||
class AuthSession;
|
||||
|
||||
constexpr auto kMaxBioLength = 70;
|
||||
|
||||
|
@ -43,10 +44,15 @@ void ShowAddParticipantsError(
|
|||
not_null<PeerData*> chat,
|
||||
const std::vector<not_null<UserData*>> &users);
|
||||
|
||||
class AddContactBox : public BoxContent, public RPCSender {
|
||||
class AddContactBox : public BoxContent {
|
||||
public:
|
||||
AddContactBox(QWidget*, QString fname = QString(), QString lname = QString(), QString phone = QString());
|
||||
AddContactBox(QWidget*, UserData *user);
|
||||
AddContactBox(QWidget*, not_null<AuthSession*> session);
|
||||
AddContactBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
QString fname,
|
||||
QString lname,
|
||||
QString phone);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
@ -61,12 +67,9 @@ private:
|
|||
void retry();
|
||||
void save();
|
||||
void updateButtons();
|
||||
void onImportDone(const MTPcontacts_ImportedContacts &res);
|
||||
void importDone(const MTPcontacts_ImportedContacts &result);
|
||||
|
||||
void onSaveUserDone(const MTPcontacts_ImportedContacts &res);
|
||||
bool onSaveUserFail(const RPCError &e);
|
||||
|
||||
UserData *_user = nullptr;
|
||||
const not_null<AuthSession*> _session;
|
||||
|
||||
object_ptr<Ui::InputField> _first;
|
||||
object_ptr<Ui::InputField> _last;
|
||||
|
@ -91,6 +94,7 @@ public:
|
|||
};
|
||||
GroupInfoBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
Type type,
|
||||
const QString &title = QString(),
|
||||
Fn<void(not_null<ChannelData*>)> channelDone = nullptr);
|
||||
|
@ -110,6 +114,8 @@ private:
|
|||
void descriptionResized();
|
||||
void updateMaxHeight();
|
||||
|
||||
const not_null<AuthSession*> _session;
|
||||
|
||||
Type _type = Type::Group;
|
||||
QString _initialTitle;
|
||||
Fn<void(not_null<ChannelData*>)> _channelDone;
|
||||
|
@ -126,7 +132,10 @@ private:
|
|||
|
||||
class SetupChannelBox : public BoxContent, public RPCSender {
|
||||
public:
|
||||
SetupChannelBox(QWidget*, ChannelData *channel, bool existing = false);
|
||||
SetupChannelBox(
|
||||
QWidget*,
|
||||
not_null<ChannelData*> channel,
|
||||
bool existing = false);
|
||||
|
||||
void setInnerFocus() override;
|
||||
|
||||
|
@ -162,7 +171,8 @@ private:
|
|||
|
||||
void showRevokePublicLinkBoxForEdit();
|
||||
|
||||
ChannelData *_channel = nullptr;
|
||||
const not_null<ChannelData*> _channel;
|
||||
|
||||
bool _existing = false;
|
||||
|
||||
std::shared_ptr<Ui::RadioenumGroup<Privacy>> _privacyGroup;
|
||||
|
@ -215,7 +225,10 @@ private:
|
|||
|
||||
class RevokePublicLinkBox : public BoxContent, public RPCSender {
|
||||
public:
|
||||
RevokePublicLinkBox(QWidget*, Fn<void()> revokeCallback);
|
||||
RevokePublicLinkBox(
|
||||
QWidget*,
|
||||
not_null<AuthSession*> session,
|
||||
Fn<void()> revokeCallback);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
@ -223,6 +236,8 @@ protected:
|
|||
void resizeEvent(QResizeEvent *e) override;
|
||||
|
||||
private:
|
||||
const not_null<AuthSession*> _session;
|
||||
|
||||
object_ptr<Ui::FlatLabel> _aboutRevoke;
|
||||
|
||||
class Inner;
|
||||
|
|
|
@ -245,6 +245,7 @@ object_ptr<Ui::RpWidget> SetupCreateGroup(
|
|||
const auto guarded = crl::guard(parent, callback);
|
||||
Ui::show(
|
||||
Box<GroupInfoBox>(
|
||||
&channel->session(),
|
||||
GroupInfoBox::Type::Megagroup,
|
||||
channel->name + " Chat",
|
||||
guarded),
|
||||
|
|
|
@ -464,7 +464,9 @@ void Controller::askUsernameRevoke() {
|
|||
checkUsernameAvailability();
|
||||
});
|
||||
Ui::show(
|
||||
Box<RevokePublicLinkBox>(std::move(revokeCallback)),
|
||||
Box<RevokePublicLinkBox>(
|
||||
&_peer->session(),
|
||||
std::move(revokeCallback)),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ StickersListWidget::Footer::Footer(not_null<StickersListWidget*> parent)
|
|||
|
||||
_iconsLeft = _iconsRight = st::emojiCategorySkip + st::stickerIconWidth;
|
||||
|
||||
subscribe(Auth().downloaderTaskFinished(), [this] {
|
||||
subscribe(_pan->session().downloaderTaskFinished(), [=] {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
@ -689,7 +689,7 @@ void StickersListWidget::Footer::paintSearchIcon(Painter &p) const {
|
|||
}
|
||||
|
||||
void StickersListWidget::Footer::paintFeaturedStickerSetsBadge(Painter &p, int iconLeft) const {
|
||||
if (auto unread = Auth().data().featuredStickerSetsUnreadCount()) {
|
||||
if (const auto unread = _pan->session().data().featuredStickerSetsUnreadCount()) {
|
||||
Dialogs::Layout::UnreadBadgeStyle unreadSt;
|
||||
unreadSt.sizeId = Dialogs::Layout::UnreadBadgeInStickersPanel;
|
||||
unreadSt.size = st::stickersSettingsUnreadSize;
|
||||
|
@ -837,7 +837,7 @@ StickersListWidget::StickersListWidget(
|
|||
Ui::show(Box<StickersBox>(StickersBox::Section::Installed));
|
||||
});
|
||||
|
||||
subscribe(Auth().downloaderTaskFinished(), [=] {
|
||||
subscribe(session().downloaderTaskFinished(), [=] {
|
||||
if (isVisible()) {
|
||||
update();
|
||||
readVisibleFeatured(getVisibleTop(), getVisibleBottom());
|
||||
|
@ -850,6 +850,10 @@ StickersListWidget::StickersListWidget(
|
|||
}));
|
||||
}
|
||||
|
||||
AuthSession &StickersListWidget::session() const {
|
||||
return controller()->session();
|
||||
}
|
||||
|
||||
rpl::producer<not_null<DocumentData*>> StickersListWidget::chosen() const {
|
||||
return _chosen.events();
|
||||
}
|
||||
|
@ -923,7 +927,7 @@ void StickersListWidget::readVisibleFeatured(
|
|||
}
|
||||
}
|
||||
if (loaded == count) {
|
||||
Auth().api().readFeaturedSetDelayed(set.id);
|
||||
session().api().readFeaturedSetDelayed(set.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1178,7 +1182,7 @@ void StickersListWidget::fillLocalSearchRows(const QString &query) {
|
|||
return true;
|
||||
};
|
||||
|
||||
const auto &sets = Auth().data().stickerSets();
|
||||
const auto &sets = session().data().stickerSets();
|
||||
for (const auto &[setId, titleWords] : _searchIndex) {
|
||||
if (allSearchWordsInTitle(titleWords)) {
|
||||
if (const auto it = sets.find(setId); it != sets.end()) {
|
||||
|
@ -1190,7 +1194,7 @@ void StickersListWidget::fillLocalSearchRows(const QString &query) {
|
|||
|
||||
void StickersListWidget::fillCloudSearchRows(
|
||||
const std::vector<uint64> &cloudSets) {
|
||||
const auto &sets = Auth().data().stickerSets();
|
||||
const auto &sets = session().data().stickerSets();
|
||||
for (const auto setId : cloudSets) {
|
||||
if (const auto it = sets.find(setId); it != sets.end()) {
|
||||
addSearchRow(&*it);
|
||||
|
@ -1266,7 +1270,7 @@ void StickersListWidget::searchResultsDone(
|
|||
setData = &d.vset().c_stickerSet();
|
||||
}
|
||||
for (const auto &cover : d.vcovers().v) {
|
||||
const auto document = Auth().data().processDocument(cover);
|
||||
const auto document = session().data().processDocument(cover);
|
||||
if (document->sticker()) {
|
||||
covers.push_back(document);
|
||||
}
|
||||
|
@ -1932,7 +1936,7 @@ void StickersListWidget::removeRecentSticker(int section, int index) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
auto &sets = Auth().data().stickerSetsRef();
|
||||
auto &sets = session().data().stickerSetsRef();
|
||||
auto it = sets.find(Stickers::CustomSetId);
|
||||
if (it != sets.cend()) {
|
||||
for (int i = 0, l = it->stickers.size(); i < l; ++i) {
|
||||
|
@ -1965,7 +1969,7 @@ void StickersListWidget::removeFavedSticker(int section, int index) {
|
|||
const auto &sticker = _mySets[section].stickers[index];
|
||||
const auto document = sticker.document;
|
||||
Stickers::SetFaved(document, false);
|
||||
Auth().api().toggleFavedSticker(
|
||||
session().api().toggleFavedSticker(
|
||||
document,
|
||||
Data::FileOriginStickerSet(Stickers::FavedSetId, 0),
|
||||
false);
|
||||
|
@ -2077,12 +2081,12 @@ void StickersListWidget::refreshStickers() {
|
|||
void StickersListWidget::refreshMySets() {
|
||||
_mySets.clear();
|
||||
_favedStickersMap.clear();
|
||||
_mySets.reserve(Auth().data().stickerSetsOrder().size() + 3);
|
||||
_mySets.reserve(session().data().stickerSetsOrder().size() + 3);
|
||||
|
||||
refreshFavedStickers();
|
||||
refreshRecentStickers(false);
|
||||
refreshMegagroupStickers(GroupStickersPlace::Visible);
|
||||
for (const auto setId : Auth().data().stickerSetsOrder()) {
|
||||
for (const auto setId : session().data().stickerSetsOrder()) {
|
||||
const auto externalLayout = false;
|
||||
appendSet(_mySets, setId, externalLayout, AppendSkip::Archived);
|
||||
}
|
||||
|
@ -2091,9 +2095,9 @@ void StickersListWidget::refreshMySets() {
|
|||
|
||||
void StickersListWidget::refreshFeaturedSets() {
|
||||
_featuredSets.clear();
|
||||
_featuredSets.reserve(Auth().data().featuredStickerSetsOrder().size());
|
||||
_featuredSets.reserve(session().data().featuredStickerSetsOrder().size());
|
||||
|
||||
for (const auto setId : Auth().data().featuredStickerSetsOrder()) {
|
||||
for (const auto setId : session().data().featuredStickerSetsOrder()) {
|
||||
const auto externalLayout = true;
|
||||
appendSet(_featuredSets, setId, externalLayout, AppendSkip::Installed);
|
||||
}
|
||||
|
@ -2102,7 +2106,7 @@ void StickersListWidget::refreshFeaturedSets() {
|
|||
void StickersListWidget::refreshSearchSets() {
|
||||
refreshSearchIndex();
|
||||
|
||||
const auto &sets = Auth().data().stickerSets();
|
||||
const auto &sets = session().data().stickerSets();
|
||||
for (auto &set : _searchSets) {
|
||||
if (const auto it = sets.find(set.id); it != sets.end()) {
|
||||
set.flags = it->flags;
|
||||
|
@ -2226,7 +2230,7 @@ void StickersListWidget::appendSet(
|
|||
uint64 setId,
|
||||
bool externalLayout,
|
||||
AppendSkip skip) {
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
if (it == sets.cend() || it->stickers.isEmpty()) {
|
||||
return;
|
||||
|
@ -2267,7 +2271,7 @@ auto StickersListWidget::collectRecentStickers() -> std::vector<Sticker> {
|
|||
_custom.clear();
|
||||
auto result = std::vector<Sticker>();
|
||||
|
||||
const auto &sets = Auth().data().stickerSets();
|
||||
const auto &sets = session().data().stickerSets();
|
||||
const auto &recent = Stickers::GetRecentPack();
|
||||
const auto customIt = sets.constFind(Stickers::CustomSetId);
|
||||
const auto cloudIt = sets.constFind(Stickers::CloudRecentSetId);
|
||||
|
@ -2353,7 +2357,7 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
|||
|
||||
void StickersListWidget::refreshFavedStickers() {
|
||||
clearSelection();
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(Stickers::FavedSetId);
|
||||
if (it == sets.cend() || it->stickers.isEmpty()) {
|
||||
return;
|
||||
|
@ -2384,7 +2388,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
};
|
||||
if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetEmpty) {
|
||||
if (canEdit) {
|
||||
auto hidden = Auth().settings().isGroupStickersSectionHidden(_megagroupSet->id);
|
||||
auto hidden = session().settings().isGroupStickersSectionHidden(_megagroupSet->id);
|
||||
if (isShownHere(hidden)) {
|
||||
const auto shortName = QString();
|
||||
const auto thumbnail = ImagePtr();
|
||||
|
@ -2402,10 +2406,10 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
auto hidden = Auth().settings().isGroupStickersSectionHidden(_megagroupSet->id);
|
||||
auto hidden = session().settings().isGroupStickersSectionHidden(_megagroupSet->id);
|
||||
auto removeHiddenForGroup = [this, &hidden] {
|
||||
if (hidden) {
|
||||
Auth().settings().removeGroupStickersSectionHidden(_megagroupSet->id);
|
||||
session().settings().removeGroupStickersSectionHidden(_megagroupSet->id);
|
||||
Local::writeUserSettings();
|
||||
hidden = false;
|
||||
}
|
||||
|
@ -2417,7 +2421,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
return;
|
||||
}
|
||||
auto &set = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID();
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(set.vid().v);
|
||||
if (it != sets.cend()) {
|
||||
auto isInstalled = (it->flags & MTPDstickerSet::Flag::f_installed_date)
|
||||
|
@ -2461,7 +2465,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
|
||||
icons.clear();
|
||||
icons.reserve(_mySets.size() + 1);
|
||||
if (Auth().data().featuredStickerSetsUnreadCount()
|
||||
if (session().data().featuredStickerSetsUnreadCount()
|
||||
&& !_featuredSets.empty()) {
|
||||
icons.push_back(StickerIcon(Stickers::FeaturedSetId));
|
||||
}
|
||||
|
@ -2510,7 +2514,7 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
|
|||
pixh));
|
||||
}
|
||||
|
||||
if (!Auth().data().featuredStickerSetsUnreadCount()
|
||||
if (!session().data().featuredStickerSetsUnreadCount()
|
||||
&& !_featuredSets.empty()) {
|
||||
icons.push_back(StickerIcon(Stickers::FeaturedSetId));
|
||||
}
|
||||
|
@ -2761,7 +2765,7 @@ void StickersListWidget::displaySet(uint64 setId) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
if (it != sets.cend()) {
|
||||
_displayingSetId = setId;
|
||||
|
@ -2776,7 +2780,7 @@ void StickersListWidget::displaySet(uint64 setId) {
|
|||
}
|
||||
|
||||
void StickersListWidget::installSet(uint64 setId) {
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
if (it != sets.cend()) {
|
||||
const auto input = Stickers::inputSetId(*it);
|
||||
|
@ -2815,7 +2819,7 @@ void StickersListWidget::sendInstallRequest(
|
|||
|
||||
void StickersListWidget::removeMegagroupSet(bool locally) {
|
||||
if (locally) {
|
||||
Auth().settings().setGroupStickersSectionHidden(_megagroupSet->id);
|
||||
session().settings().setGroupStickersSectionHidden(_megagroupSet->id);
|
||||
Local::writeUserSettings();
|
||||
refreshStickers();
|
||||
return;
|
||||
|
@ -2825,7 +2829,7 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
|||
Expects(group->mgInfo != nullptr);
|
||||
|
||||
if (group->mgInfo->stickerSet.type() != mtpc_inputStickerSetEmpty) {
|
||||
Auth().api().setGroupStickerSet(group, MTP_inputStickerSetEmpty());
|
||||
session().api().setGroupStickerSet(group, MTP_inputStickerSetEmpty());
|
||||
}
|
||||
Ui::hideLayer();
|
||||
_removingSetId = 0;
|
||||
|
@ -2837,14 +2841,14 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
|||
}
|
||||
|
||||
void StickersListWidget::removeSet(uint64 setId) {
|
||||
auto &sets = Auth().data().stickerSets();
|
||||
auto &sets = session().data().stickerSets();
|
||||
auto it = sets.constFind(setId);
|
||||
if (it != sets.cend()) {
|
||||
_removingSetId = it->id;
|
||||
auto text = tr::lng_stickers_remove_pack(tr::now, lt_sticker_pack, it->title);
|
||||
Ui::show(Box<ConfirmBox>(text, tr::lng_stickers_remove_pack_confirm(tr::now), crl::guard(this, [=] {
|
||||
Ui::hideLayer();
|
||||
auto &sets = Auth().data().stickerSetsRef();
|
||||
auto &sets = session().data().stickerSetsRef();
|
||||
auto it = sets.find(_removingSetId);
|
||||
if (it != sets.cend()) {
|
||||
if (it->id && it->access) {
|
||||
|
@ -2871,8 +2875,8 @@ void StickersListWidget::removeSet(uint64 setId) {
|
|||
// && !(it->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||
// sets.erase(it);
|
||||
//}
|
||||
int removeIndex = Auth().data().stickerSetsOrder().indexOf(_removingSetId);
|
||||
if (removeIndex >= 0) Auth().data().stickerSetsOrderRef().removeAt(removeIndex);
|
||||
int removeIndex = session().data().stickerSetsOrder().indexOf(_removingSetId);
|
||||
if (removeIndex >= 0) session().data().stickerSetsOrderRef().removeAt(removeIndex);
|
||||
refreshStickers();
|
||||
Local::writeInstalledStickers();
|
||||
if (writeRecent) Local::writeUserSettings();
|
||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/variant.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class AuthSession;
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
@ -40,6 +42,8 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
rpl::producer<not_null<DocumentData*>> chosen() const;
|
||||
rpl::producer<> scrollUpdated() const;
|
||||
rpl::producer<> checkForHide() const;
|
||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/discrete_sliders.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/image/image_prepare.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -279,17 +280,18 @@ TabbedSelector::TabbedSelector(
|
|||
not_null<Window::SessionController*> controller,
|
||||
Mode mode)
|
||||
: RpWidget(parent)
|
||||
, _controller(controller)
|
||||
, _mode(mode)
|
||||
, _topShadow(full() ? object_ptr<Ui::PlainShadow>(this) : nullptr)
|
||||
, _bottomShadow(this)
|
||||
, _scroll(this, st::emojiScroll)
|
||||
, _tabs { {
|
||||
createTab(SelectorTab::Emoji, controller),
|
||||
createTab(SelectorTab::Stickers, controller),
|
||||
createTab(SelectorTab::Gifs, controller),
|
||||
createTab(SelectorTab::Emoji),
|
||||
createTab(SelectorTab::Stickers),
|
||||
createTab(SelectorTab::Gifs),
|
||||
} }
|
||||
, _currentTabType(full()
|
||||
? Auth().settings().selectorTab()
|
||||
? session().settings().selectorTab()
|
||||
: SelectorTab::Emoji) {
|
||||
resize(st::emojiPanWidth, st::emojiPanMaxHeight);
|
||||
|
||||
|
@ -355,7 +357,7 @@ TabbedSelector::TabbedSelector(
|
|||
Notify::PeerUpdate::Flag::RightsChanged,
|
||||
handleUpdate));
|
||||
|
||||
Auth().api().stickerSetInstalled(
|
||||
session().api().stickerSetInstalled(
|
||||
) | rpl::start_with_next([this](uint64 setId) {
|
||||
_tabsSlider->setActiveSection(
|
||||
static_cast<int>(SelectorTab::Stickers));
|
||||
|
@ -368,22 +370,28 @@ TabbedSelector::TabbedSelector(
|
|||
showAll();
|
||||
}
|
||||
|
||||
TabbedSelector::Tab TabbedSelector::createTab(SelectorTab type, not_null<Window::SessionController*> controller) {
|
||||
auto createWidget = [&]() -> object_ptr<Inner> {
|
||||
if (!full() && type != SelectorTab::Emoji) {
|
||||
return { nullptr };
|
||||
}
|
||||
switch (type) {
|
||||
case SelectorTab::Emoji:
|
||||
return object_ptr<EmojiListWidget>(this, controller);
|
||||
case SelectorTab::Stickers:
|
||||
return object_ptr<StickersListWidget>(this, controller);
|
||||
case SelectorTab::Gifs:
|
||||
return object_ptr<GifsListWidget>(this, controller);
|
||||
}
|
||||
Unexpected("Type in TabbedSelector::createTab.");
|
||||
};
|
||||
return Tab{ type, createWidget() };
|
||||
TabbedSelector::~TabbedSelector() = default;
|
||||
|
||||
AuthSession &TabbedSelector::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
TabbedSelector::Tab TabbedSelector::createTab(SelectorTab type) {
|
||||
auto createWidget = [&]() -> object_ptr<Inner> {
|
||||
if (!full() && type != SelectorTab::Emoji) {
|
||||
return { nullptr };
|
||||
}
|
||||
switch (type) {
|
||||
case SelectorTab::Emoji:
|
||||
return object_ptr<EmojiListWidget>(this, _controller);
|
||||
case SelectorTab::Stickers:
|
||||
return object_ptr<StickersListWidget>(this, _controller);
|
||||
case SelectorTab::Gifs:
|
||||
return object_ptr<GifsListWidget>(this, _controller);
|
||||
}
|
||||
Unexpected("Type in TabbedSelector::createTab.");
|
||||
};
|
||||
return Tab{ type, createWidget() };
|
||||
}
|
||||
|
||||
bool TabbedSelector::full() const {
|
||||
|
@ -602,8 +610,6 @@ QRect TabbedSelector::rectForFloatPlayer() const {
|
|||
return mapToGlobal(_scroll->geometry());
|
||||
}
|
||||
|
||||
TabbedSelector::~TabbedSelector() = default;
|
||||
|
||||
void TabbedSelector::hideFinished() {
|
||||
for (auto &tab : _tabs) {
|
||||
if (!tab.widget()) {
|
||||
|
@ -617,7 +623,7 @@ void TabbedSelector::hideFinished() {
|
|||
|
||||
void TabbedSelector::showStarted() {
|
||||
if (full()) {
|
||||
Auth().api().updateStickers();
|
||||
session().api().updateStickers();
|
||||
}
|
||||
currentTab()->widget()->refreshRecent();
|
||||
currentTab()->widget()->preloadImages();
|
||||
|
@ -818,8 +824,8 @@ void TabbedSelector::switchTab() {
|
|||
update();
|
||||
|
||||
if (full()) {
|
||||
Auth().settings().setSelectorTab(_currentTabType);
|
||||
Auth().saveSettingsDelayed();
|
||||
session().settings().setSelectorTab(_currentTabType);
|
||||
session().saveSettingsDelayed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller,
|
||||
Mode mode = Mode::Full);
|
||||
~TabbedSelector();
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
rpl::producer<EmojiPtr> emojiChosen() const;
|
||||
rpl::producer<not_null<DocumentData*>> fileChosen() const;
|
||||
|
@ -99,8 +102,6 @@ public:
|
|||
return _showRequests.events();
|
||||
}
|
||||
|
||||
~TabbedSelector();
|
||||
|
||||
class Inner;
|
||||
class InnerFooter;
|
||||
|
||||
|
@ -146,9 +147,7 @@ private:
|
|||
};
|
||||
|
||||
bool full() const;
|
||||
Tab createTab(
|
||||
SelectorTab type,
|
||||
not_null<Window::SessionController*> controller);
|
||||
Tab createTab(SelectorTab type);
|
||||
|
||||
void paintSlideFrame(Painter &p);
|
||||
void paintContent(Painter &p);
|
||||
|
@ -185,6 +184,8 @@ private:
|
|||
not_null<StickersListWidget*> stickers() const;
|
||||
not_null<GifsListWidget*> gifs() const;
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
|
||||
Mode _mode = Mode::Full;
|
||||
int _roundRadius = 0;
|
||||
int _footerTop = 0;
|
||||
|
|
|
@ -737,11 +737,11 @@ void DocumentData::automaticLoad(
|
|||
const auto shouldLoadFromCloud = !Data::IsExecutableName(filename)
|
||||
&& (item
|
||||
? Data::AutoDownload::Should(
|
||||
Auth().settings().autoDownload(),
|
||||
session().settings().autoDownload(),
|
||||
item->history()->peer,
|
||||
this)
|
||||
: Data::AutoDownload::Should(
|
||||
Auth().settings().autoDownload(),
|
||||
session().settings().autoDownload(),
|
||||
this));
|
||||
const auto loadFromCloud = shouldLoadFromCloud
|
||||
? LoadFromCloudOrLocal
|
||||
|
|
|
@ -1645,7 +1645,7 @@ bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
|||
}
|
||||
requestItemTextRefresh(existing);
|
||||
if (existing->mainView()) {
|
||||
App::checkSavedGif(existing);
|
||||
checkSavedGif(existing);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1653,6 +1653,40 @@ bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void Session::addSavedGif(not_null<DocumentData*> document) {
|
||||
const auto index = _savedGifs.indexOf(document);
|
||||
if (!index) {
|
||||
return;
|
||||
}
|
||||
if (index > 0) {
|
||||
_savedGifs.remove(index);
|
||||
}
|
||||
_savedGifs.push_front(document);
|
||||
if (_savedGifs.size() > Global::SavedGifsLimit()) {
|
||||
_savedGifs.pop_back();
|
||||
}
|
||||
Local::writeSavedGifs();
|
||||
|
||||
notifySavedGifsUpdated();
|
||||
setLastSavedGifsUpdate(0);
|
||||
session().api().updateStickers();
|
||||
}
|
||||
|
||||
void Session::checkSavedGif(not_null<HistoryItem*> item) {
|
||||
if (item->Has<HistoryMessageForwarded>()
|
||||
|| (!item->out()
|
||||
&& item->history()->peer != session().user())) {
|
||||
return;
|
||||
}
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
if (document->isGifv()) {
|
||||
addSavedGif(document);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Session::updateEditedMessage(const MTPMessage &data) {
|
||||
const auto existing = data.match([](const MTPDmessageEmpty &)
|
||||
-> HistoryItem* {
|
||||
|
|
|
@ -309,6 +309,9 @@ public:
|
|||
return _savedGifs;
|
||||
}
|
||||
|
||||
void addSavedGif(not_null<DocumentData*> document);
|
||||
void checkSavedGif(not_null<HistoryItem*> item);
|
||||
|
||||
HistoryItemsList idsToItems(const MessageIdsList &ids) const;
|
||||
MessageIdsList itemsToIds(const HistoryItemsList &items) const;
|
||||
MessageIdsList itemOrItsGroup(not_null<HistoryItem*> item) const;
|
||||
|
|
|
@ -115,7 +115,9 @@ void activateBotCommand(
|
|||
Ui::showPeerHistory(history, ShowAtTheEndMsgId);
|
||||
auto options = ApiWrap::SendOptions(history);
|
||||
options.replyTo = msgId;
|
||||
history->session().api().shareContact(Auth().user(), options);
|
||||
history->session().api().shareContact(
|
||||
history->session().user(),
|
||||
options);
|
||||
}));
|
||||
} break;
|
||||
|
||||
|
|
|
@ -227,25 +227,25 @@ InnerWidget::InnerWidget(
|
|||
, _idManager(_history->adminLogIdManager()) {
|
||||
setMouseTracking(true);
|
||||
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
|
||||
Auth().data().viewRepaintRequest(
|
||||
session().data().viewRepaintRequest(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
repaintItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().viewResizeRequest(
|
||||
session().data().viewResizeRequest(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
resizeItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().itemViewRefreshRequest(
|
||||
session().data().itemViewRefreshRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
refreshItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().viewLayoutChanged(
|
||||
session().data().viewLayoutChanged(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
if (view->isUnderCursor()) {
|
||||
|
@ -253,7 +253,7 @@ InnerWidget::InnerWidget(
|
|||
}
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().animationPlayInlineRequest(
|
||||
session().data().animationPlayInlineRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
if (const auto media = view->media()) {
|
||||
|
@ -261,7 +261,7 @@ InnerWidget::InnerWidget(
|
|||
}
|
||||
}
|
||||
}, lifetime());
|
||||
subscribe(Auth().data().queryItemVisibility(), [this](const Data::Session::ItemVisibilityQuery &query) {
|
||||
subscribe(session().data().queryItemVisibility(), [this](const Data::Session::ItemVisibilityQuery &query) {
|
||||
if (_history != query.item->history() || !query.item->isLogEntry() || !isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
@ -277,6 +277,10 @@ InnerWidget::InnerWidget(
|
|||
requestAdmins();
|
||||
}
|
||||
|
||||
AuthSession &InnerWidget::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void InnerWidget::visibleTopBottomUpdated(
|
||||
int visibleTop,
|
||||
int visibleBottom) {
|
||||
|
@ -389,7 +393,7 @@ void InnerWidget::requestAdmins() {
|
|||
MTP_int(kMaxChannelAdmins),
|
||||
MTP_int(participantsHash)
|
||||
)).done([this](const MTPchannels_ChannelParticipants &result) {
|
||||
Auth().api().parseChannelParticipants(_channel, result, [&](
|
||||
session().api().parseChannelParticipants(_channel, result, [&](
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list) {
|
||||
auto filtered = (
|
||||
|
@ -407,7 +411,7 @@ void InnerWidget::requestAdmins() {
|
|||
return std::make_pair(userId, canEdit);
|
||||
}) | ranges::view::transform([&](auto &&pair) {
|
||||
return std::make_pair(
|
||||
Auth().data().userLoaded(pair.first),
|
||||
session().data().userLoaded(pair.first),
|
||||
pair.second);
|
||||
}) | ranges::view::filter([&](auto &&pair) {
|
||||
return (pair.first != nullptr);
|
||||
|
@ -421,7 +425,7 @@ void InnerWidget::requestAdmins() {
|
|||
}
|
||||
});
|
||||
if (_admins.empty()) {
|
||||
_admins.push_back(Auth().user());
|
||||
_admins.push_back(session().user());
|
||||
}
|
||||
if (_showFilterCallback) {
|
||||
showFilter(std::move(_showFilterCallback));
|
||||
|
@ -514,7 +518,7 @@ bool InnerWidget::elementUnderCursor(
|
|||
void InnerWidget::elementAnimationAutoplayAsync(
|
||||
not_null<const HistoryView::Element*> view) {
|
||||
crl::on_main(this, [this, msgId = view->data()->fullId()] {
|
||||
if (const auto item = Auth().data().message(msgId)) {
|
||||
if (const auto item = session().data().message(msgId)) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
if (const auto media = view->media()) {
|
||||
media->autoplayAnimation();
|
||||
|
@ -1144,7 +1148,7 @@ void InnerWidget::showContextInFolder(not_null<DocumentData*> document) {
|
|||
}
|
||||
|
||||
void InnerWidget::openContextGif(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
Core::App().showDocument(document, item);
|
||||
|
@ -1154,7 +1158,7 @@ void InnerWidget::openContextGif(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void InnerWidget::copyContextText(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
SetClipboardText(HistoryItemText(item));
|
||||
}
|
||||
}
|
||||
|
@ -1612,7 +1616,7 @@ void InnerWidget::performDrag() {
|
|||
// if (uponSelected && !Adaptive::OneColumn()) {
|
||||
// auto selectedState = getSelectionState();
|
||||
// if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {
|
||||
// Auth().data().setMimeForwardIds(getSelectedItems());
|
||||
// session().data().setMimeForwardIds(getSelectedItems());
|
||||
// mimeData->setData(qsl("application/x-td-forward"), "1");
|
||||
// }
|
||||
// }
|
||||
|
@ -1626,8 +1630,8 @@ void InnerWidget::performDrag() {
|
|||
// if (_mouseCursorState == CursorState::Date
|
||||
// || (pressedMedia && pressedMedia->dragItem())) {
|
||||
// forwardMimeType = qsl("application/x-td-forward");
|
||||
// Auth().data().setMimeForwardIds(
|
||||
// Auth().data().itemOrItsGroup(pressedItem->data()));
|
||||
// session().data().setMimeForwardIds(
|
||||
// session().data().itemOrItsGroup(pressedItem->data()));
|
||||
// }
|
||||
// }
|
||||
// if (auto pressedLnkItem = App::pressedLinkItem()) {
|
||||
|
@ -1635,7 +1639,7 @@ void InnerWidget::performDrag() {
|
|||
// if (forwardMimeType.isEmpty()
|
||||
// && pressedMedia->dragItemByHandler(pressedHandler)) {
|
||||
// forwardMimeType = qsl("application/x-td-forward");
|
||||
// Auth().data().setMimeForwardIds(
|
||||
// session().data().setMimeForwardIds(
|
||||
// { 1, pressedLnkItem->fullId() });
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -16,6 +16,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "mtproto/sender.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
class AuthSession;
|
||||
|
||||
namespace HistoryView {
|
||||
class Element;
|
||||
struct TextState;
|
||||
|
@ -48,6 +50,8 @@ public:
|
|||
not_null<Window::SessionController*> controller,
|
||||
not_null<ChannelData*> channel);
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
base::Observable<void> showSearchSignal;
|
||||
base::Observable<int> scrollToSignal;
|
||||
base::Observable<void> cancelledSignal;
|
||||
|
|
|
@ -1005,7 +1005,7 @@ void History::applyMessageChanges(
|
|||
if (data.type() == mtpc_messageService) {
|
||||
applyServiceChanges(item, data.c_messageService());
|
||||
}
|
||||
App::checkSavedGif(item);
|
||||
owner().checkSavedGif(item);
|
||||
}
|
||||
|
||||
void History::applyServiceChanges(
|
||||
|
|
|
@ -153,31 +153,31 @@ HistoryInner::HistoryInner(
|
|||
subscribe(_controller->window()->dragFinished(), [this] {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
});
|
||||
Auth().data().itemRemoved(
|
||||
session().data().itemRemoved(
|
||||
) | rpl::start_with_next(
|
||||
[this](auto item) { itemRemoved(item); },
|
||||
lifetime());
|
||||
Auth().data().viewRemoved(
|
||||
session().data().viewRemoved(
|
||||
) | rpl::start_with_next(
|
||||
[this](auto view) { viewRemoved(view); },
|
||||
lifetime());
|
||||
Auth().data().itemViewRefreshRequest(
|
||||
session().data().itemViewRefreshRequest(
|
||||
) | rpl::start_with_next(
|
||||
[this](auto item) { refreshView(item); },
|
||||
lifetime());
|
||||
rpl::merge(
|
||||
Auth().data().historyUnloaded(),
|
||||
Auth().data().historyCleared()
|
||||
session().data().historyUnloaded(),
|
||||
session().data().historyCleared()
|
||||
) | rpl::filter([this](not_null<const History*> history) {
|
||||
return (_history == history);
|
||||
}) | rpl::start_with_next([this] {
|
||||
mouseActionCancel();
|
||||
}, lifetime());
|
||||
Auth().data().viewRepaintRequest(
|
||||
session().data().viewRepaintRequest(
|
||||
) | rpl::start_with_next([this](not_null<const Element*> view) {
|
||||
repaintItem(view);
|
||||
}, lifetime());
|
||||
Auth().data().viewLayoutChanged(
|
||||
session().data().viewLayoutChanged(
|
||||
) | rpl::filter([](not_null<const Element*> view) {
|
||||
return (view == view->data()->mainView()) && view->isUnderCursor();
|
||||
}) | rpl::start_with_next([this](not_null<const Element*> view) {
|
||||
|
@ -185,6 +185,10 @@ HistoryInner::HistoryInner(
|
|||
}, lifetime());
|
||||
}
|
||||
|
||||
AuthSession &HistoryInner::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void HistoryInner::messagesReceived(
|
||||
PeerData *peer,
|
||||
const QVector<MTPMessage> &messages) {
|
||||
|
@ -493,7 +497,7 @@ TextSelection HistoryInner::computeRenderSelection(
|
|||
if (result != TextSelection() && result != FullSelection) {
|
||||
return result;
|
||||
}
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
auto parts = TextSelection();
|
||||
auto allFullSelected = true;
|
||||
const auto count = int(group->items.size());
|
||||
|
@ -681,7 +685,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
|
||||
if (!readMentions.empty() && App::wnd()->doWeReadMentions()) {
|
||||
Auth().api().markMediaRead(readMentions);
|
||||
session().api().markMediaRead(readMentions);
|
||||
}
|
||||
|
||||
if (mtop >= 0 || htop >= 0) {
|
||||
|
@ -1183,7 +1187,7 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
|||
if (uponSelected && !Adaptive::OneColumn()) {
|
||||
auto selectedState = getSelectionState();
|
||||
if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {
|
||||
Auth().data().setMimeForwardIds(getSelectedItems());
|
||||
session().data().setMimeForwardIds(getSelectedItems());
|
||||
mimeData->setData(qsl("application/x-td-forward"), "1");
|
||||
}
|
||||
}
|
||||
|
@ -1195,7 +1199,7 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
|||
}
|
||||
auto forwardIds = MessageIdsList();
|
||||
if (_mouseCursorState == CursorState::Date) {
|
||||
forwardIds = Auth().data().itemOrItsGroup(_dragStateItem);
|
||||
forwardIds = session().data().itemOrItsGroup(_dragStateItem);
|
||||
} else if (view->isHiddenByGroup() && pressedHandler) {
|
||||
forwardIds = MessageIdsList(1, _dragStateItem->fullId());
|
||||
} else if (const auto media = view->media()) {
|
||||
|
@ -1207,7 +1211,7 @@ std::unique_ptr<QMimeData> HistoryInner::prepareDrag() {
|
|||
if (forwardIds.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
Auth().data().setMimeForwardIds(std::move(forwardIds));
|
||||
session().data().setMimeForwardIds(std::move(forwardIds));
|
||||
auto result = std::make_unique<QMimeData>();
|
||||
result->setData(qsl("application/x-td-forward"), "1");
|
||||
if (const auto media = view->media()) {
|
||||
|
@ -1534,7 +1538,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
});
|
||||
if (photo->hasSticker) {
|
||||
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
|
||||
Auth().api().requestAttachedStickerSets(photo);
|
||||
session().api().requestAttachedStickerSets(photo);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1628,7 +1632,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if (IsServerMsgId(item->id) && !item->serviceMsg()) {
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelection(&_selected, item, SelectAction::Select);
|
||||
repaintItem(item);
|
||||
|
@ -1645,7 +1649,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
: App::hoveredLinkItem()
|
||||
? App::hoveredLinkItem()->data().get()
|
||||
: nullptr) {
|
||||
if (const auto group = Auth().data().groups().find(result)) {
|
||||
if (const auto group = session().data().groups().find(result)) {
|
||||
return group->items.front();
|
||||
}
|
||||
return result;
|
||||
|
@ -1680,7 +1684,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
showStickerPackInfo(document);
|
||||
});
|
||||
_menu->addAction(Stickers::IsFaved(document) ? tr::lng_faved_stickers_remove(tr::now) : tr::lng_faved_stickers_add(tr::now), [=] {
|
||||
Auth().api().toggleFavedSticker(
|
||||
session().api().toggleFavedSticker(
|
||||
document,
|
||||
itemId,
|
||||
!Stickers::IsFaved(document));
|
||||
|
@ -1696,7 +1700,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
if (!poll->closed) {
|
||||
if (poll->voted()) {
|
||||
_menu->addAction(tr::lng_polls_retract(tr::now), [=] {
|
||||
Auth().api().sendPollVotes(itemId, {});
|
||||
session().api().sendPollVotes(itemId, {});
|
||||
});
|
||||
}
|
||||
if (item->canStopPoll()) {
|
||||
|
@ -1768,7 +1772,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
}
|
||||
if (item->id > 0 && !item->serviceMsg()) {
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelectionAsGroup(&_selected, item, SelectAction::Select);
|
||||
repaintItem(view);
|
||||
|
@ -1783,7 +1787,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
&& !App::mousedItem()->data()->serviceMsg()) {
|
||||
const auto itemId = App::mousedItem()->data()->fullId();
|
||||
_menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto view = item->mainView()) {
|
||||
changeSelectionAsGroup(&_selected, item, SelectAction::Select);
|
||||
repaintItem(item);
|
||||
|
@ -1857,7 +1861,7 @@ void HistoryInner::saveDocumentToFile(
|
|||
}
|
||||
|
||||
void HistoryInner::openContextGif(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
Core::App().showDocument(document, item);
|
||||
|
@ -1867,18 +1871,18 @@ void HistoryInner::openContextGif(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void HistoryInner::saveContextGif(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto document = media->document()) {
|
||||
Auth().api().toggleSavedGif(document, item->fullId(), true);
|
||||
session().api().toggleSavedGif(document, item->fullId(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryInner::copyContextText(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
SetClipboardText(HistoryGroupText(group));
|
||||
} else {
|
||||
SetClipboardText(HistoryItemText(item));
|
||||
|
@ -1937,7 +1941,7 @@ TextForMimeData HistoryInner::getSelectedText() const {
|
|||
};
|
||||
|
||||
for (const auto [item, selection] : selected) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
if (groups.contains(group)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2149,7 +2153,7 @@ void HistoryInner::visibleAreaUpdated(int top, int bottom) {
|
|||
const auto pages = kUnloadHeavyPartsPages;
|
||||
const auto from = _visibleAreaTop - pages * visibleAreaHeight;
|
||||
const auto till = _visibleAreaBottom + pages * visibleAreaHeight;
|
||||
Auth().data().unloadHeavyViewParts(ElementDelegate(), from, till);
|
||||
session().data().unloadHeavyViewParts(ElementDelegate(), from, till);
|
||||
}
|
||||
|
||||
bool HistoryInner::displayScrollDate() const {
|
||||
|
@ -2494,7 +2498,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
dragState = TextState(nullptr, _botAbout->info->text.getState(
|
||||
point - _botAbout->rect.topLeft() - QPoint(st::msgPadding.left(), st::msgPadding.top() + st::botDescSkip + st::msgNameFont->height),
|
||||
_botAbout->width));
|
||||
_dragStateItem = Auth().data().message(dragState.itemId);
|
||||
_dragStateItem = session().data().message(dragState.itemId);
|
||||
lnkhost = _botAbout.get();
|
||||
}
|
||||
} else if (item) {
|
||||
|
@ -2552,7 +2556,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
dragState = TextState(
|
||||
nullptr,
|
||||
_scrollDateLink);
|
||||
_dragStateItem = Auth().data().message(dragState.itemId);
|
||||
_dragStateItem = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
}
|
||||
}
|
||||
|
@ -2568,7 +2572,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
selectingText = false;
|
||||
}
|
||||
dragState = view->textState(m, request);
|
||||
_dragStateItem = Auth().data().message(dragState.itemId);
|
||||
_dragStateItem = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
if (!dragState.link && m.x() >= st::historyPhotoLeft && m.x() < st::historyPhotoLeft + st::msgPhotoSize) {
|
||||
if (auto msg = item->toHistoryMessage()) {
|
||||
|
@ -2588,7 +2592,7 @@ void HistoryInner::mouseActionUpdate() {
|
|||
dragState = TextState(nullptr, from
|
||||
? from->openLink()
|
||||
: hiddenUserpicLink(message->fullId()));
|
||||
_dragStateItem = Auth().data().message(dragState.itemId);
|
||||
_dragStateItem = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
return false;
|
||||
}
|
||||
|
@ -2826,7 +2830,7 @@ void HistoryInner::notifyIsBotChanged() {
|
|||
if (newinfo) {
|
||||
_botAbout = std::make_unique<BotAbout>(this, newinfo);
|
||||
if (newinfo && !newinfo->inited) {
|
||||
Auth().api().requestFullPeer(_peer);
|
||||
session().api().requestFullPeer(_peer);
|
||||
}
|
||||
} else {
|
||||
_botAbout = nullptr;
|
||||
|
@ -2877,7 +2881,7 @@ bool HistoryInner::isSelectedGroup(
|
|||
bool HistoryInner::isSelectedAsGroup(
|
||||
not_null<SelectedItems*> toItems,
|
||||
not_null<HistoryItem*> item) const {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
return isSelectedGroup(toItems, group);
|
||||
}
|
||||
return isSelected(toItems, item);
|
||||
|
@ -2940,7 +2944,7 @@ void HistoryInner::changeSelectionAsGroup(
|
|||
not_null<SelectedItems*> toItems,
|
||||
not_null<HistoryItem*> item,
|
||||
SelectAction action) const {
|
||||
const auto group = Auth().data().groups().find(item);
|
||||
const auto group = session().data().groups().find(item);
|
||||
if (!group) {
|
||||
return changeSelection(toItems, item, action);
|
||||
}
|
||||
|
@ -2974,13 +2978,13 @@ void HistoryInner::forwardItem(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void HistoryInner::forwardAsGroup(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
Window::ShowForwardMessagesBox(Auth().data().itemOrItsGroup(item));
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
Window::ShowForwardMessagesBox(session().data().itemOrItsGroup(item));
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryInner::deleteItem(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
deleteItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -3002,13 +3006,13 @@ bool HistoryInner::hasPendingResizedItems() const {
|
|||
}
|
||||
|
||||
void HistoryInner::deleteAsGroup(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
const auto group = Auth().data().groups().find(item);
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
const auto group = session().data().groups().find(item);
|
||||
if (!group) {
|
||||
return deleteItem(item);
|
||||
}
|
||||
Ui::show(Box<DeleteMessagesBox>(
|
||||
Auth().data().itemsToIds(group->items)));
|
||||
session().data().itemsToIds(group->items)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3017,14 +3021,14 @@ void HistoryInner::reportItem(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void HistoryInner::reportAsGroup(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
const auto group = Auth().data().groups().find(item);
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
const auto group = session().data().groups().find(item);
|
||||
if (!group) {
|
||||
return reportItem(itemId);
|
||||
}
|
||||
Ui::show(Box<ReportBox>(
|
||||
_peer,
|
||||
Auth().data().itemsToIds(group->items)));
|
||||
session().data().itemsToIds(group->items)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
Ui::ScrollArea *scroll,
|
||||
not_null<History*> history);
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
void messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages);
|
||||
void messagesReceivedDown(PeerData *peer, const QVector<MTPMessage> &messages);
|
||||
|
||||
|
|
|
@ -184,17 +184,18 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
|||
base::flat_set<mtpRequestId> requests;
|
||||
};
|
||||
const auto history = item->history();
|
||||
const auto owner = &history->owner();
|
||||
const auto data = std::make_shared<ShareData>(
|
||||
history->peer,
|
||||
history->owner().itemOrItsGroup(item));
|
||||
const auto isGroup = (history->owner().groups().find(item) != nullptr);
|
||||
owner->itemOrItsGroup(item));
|
||||
const auto isGroup = (owner->groups().find(item) != nullptr);
|
||||
const auto isGame = item->getMessageBot()
|
||||
&& item->media()
|
||||
&& (item->media()->game() != nullptr);
|
||||
const auto canCopyLink = item->hasDirectLink() || isGame;
|
||||
|
||||
auto copyCallback = [=]() {
|
||||
if (auto item = Auth().data().message(data->msgIds[0])) {
|
||||
if (const auto item = owner->message(data->msgIds[0])) {
|
||||
if (item->hasDirectLink()) {
|
||||
HistoryView::CopyPostLink(item->fullId());
|
||||
} else if (const auto bot = item->getMessageBot()) {
|
||||
|
@ -321,7 +322,7 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
|||
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
const FullMsgId &msgId) {
|
||||
return [dependent = msgId](ChannelData *channel, MsgId msgId) {
|
||||
if (auto item = Auth().data().message(dependent)) {
|
||||
if (const auto item = Auth().data().message(dependent)) {
|
||||
item->updateDependencyItem();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,11 +42,14 @@ ClickHandlerPtr sendMessageClickHandler(PeerData *peer) {
|
|||
}
|
||||
|
||||
ClickHandlerPtr addContactClickHandler(not_null<HistoryItem*> item) {
|
||||
return std::make_shared<LambdaClickHandler>([fullId = item->fullId()] {
|
||||
if (const auto item = Auth().data().message(fullId)) {
|
||||
const auto session = &item->history()->session();
|
||||
const auto fullId = item->fullId();
|
||||
return std::make_shared<LambdaClickHandler>([=] {
|
||||
if (const auto item = session->data().message(fullId)) {
|
||||
if (const auto media = item->media()) {
|
||||
if (const auto contact = media->sharedContact()) {
|
||||
Ui::show(Box<AddContactBox>(
|
||||
session,
|
||||
contact->firstName,
|
||||
contact->lastName,
|
||||
contact->phoneNumber));
|
||||
|
|
|
@ -64,7 +64,7 @@ void SavePhotoToFile(not_null<PhotoData*> photo) {
|
|||
tr::lng_save_photo(tr::now),
|
||||
qsl("JPEG Image (*.jpg);;") + FileDialog::AllFilesFilter(),
|
||||
filedialogDefaultName(qsl("photo"), qsl(".jpg")),
|
||||
crl::guard(&Auth(), [=](const QString &result) {
|
||||
crl::guard(&photo->session(), [=](const QString &result) {
|
||||
if (!result.isEmpty()) {
|
||||
photo->large()->original().save(result, "JPG");
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ void ShowStickerPackInfo(not_null<DocumentData*> document) {
|
|||
void ToggleFavedSticker(
|
||||
not_null<DocumentData*> document,
|
||||
FullMsgId contextId) {
|
||||
Auth().api().toggleFavedSticker(
|
||||
document->session().api().toggleFavedSticker(
|
||||
document,
|
||||
contextId,
|
||||
!Stickers::IsFaved(document));
|
||||
|
@ -99,7 +99,7 @@ void AddPhotoActions(
|
|||
tr::lng_context_save_image(tr::now),
|
||||
App::LambdaDelayed(
|
||||
st::defaultDropdownMenu.menu.ripple.hideDuration,
|
||||
&Auth(),
|
||||
&photo->session(),
|
||||
[=] { SavePhotoToFile(photo); }));
|
||||
menu->addAction(tr::lng_context_copy_image(tr::now), [=] {
|
||||
CopyImage(photo);
|
||||
|
@ -147,7 +147,7 @@ void AddSaveDocumentAction(
|
|||
: tr::lng_context_save_file(tr::now))))),
|
||||
App::LambdaDelayed(
|
||||
st::defaultDropdownMenu.menu.ripple.hideDuration,
|
||||
&Auth(),
|
||||
&document->session(),
|
||||
save));
|
||||
}
|
||||
|
||||
|
@ -255,9 +255,10 @@ bool AddForwardMessageAction(
|
|||
} else if (!item || !item->allowsForward()) {
|
||||
return false;
|
||||
}
|
||||
const auto owner = &item->history()->owner();
|
||||
const auto asGroup = (request.pointState != PointState::GroupPart);
|
||||
if (asGroup) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = owner->groups().find(item)) {
|
||||
if (ranges::find_if(group->items, [](auto item) {
|
||||
return !item->allowsForward();
|
||||
}) != end(group->items)) {
|
||||
|
@ -267,9 +268,9 @@ bool AddForwardMessageAction(
|
|||
}
|
||||
const auto itemId = item->fullId();
|
||||
menu->addAction(tr::lng_context_forward_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
Window::ShowForwardMessagesBox(asGroup
|
||||
? Auth().data().itemOrItsGroup(item)
|
||||
? owner->itemOrItsGroup(item)
|
||||
: MessageIdsList{ 1, itemId });
|
||||
}
|
||||
});
|
||||
|
@ -320,9 +321,10 @@ bool AddDeleteMessageAction(
|
|||
} else if (!item || !item->canDelete()) {
|
||||
return false;
|
||||
}
|
||||
const auto owner = &item->history()->owner();
|
||||
const auto asGroup = (request.pointState != PointState::GroupPart);
|
||||
if (asGroup) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = owner->groups().find(item)) {
|
||||
if (ranges::find_if(group->items, [](auto item) {
|
||||
return !IsServerMsgId(item->id) || !item->canDelete();
|
||||
}) != end(group->items)) {
|
||||
|
@ -332,11 +334,11 @@ bool AddDeleteMessageAction(
|
|||
}
|
||||
const auto itemId = item->fullId();
|
||||
menu->addAction(tr::lng_context_delete_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (asGroup) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = owner->groups().find(item)) {
|
||||
Ui::show(Box<DeleteMessagesBox>(
|
||||
Auth().data().itemsToIds(group->items)));
|
||||
owner->itemsToIds(group->items)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -385,10 +387,11 @@ bool AddSelectMessageAction(
|
|||
} else if (!item || !IsServerMsgId(item->id) || item->serviceMsg()) {
|
||||
return false;
|
||||
}
|
||||
const auto owner = &item->history()->owner();
|
||||
const auto itemId = item->fullId();
|
||||
const auto asGroup = (request.pointState != PointState::GroupPart);
|
||||
menu->addAction(tr::lng_context_select_msg(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (asGroup) {
|
||||
list->selectItemAsGroup(item);
|
||||
} else {
|
||||
|
@ -485,6 +488,7 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
// AddToggleGroupingAction(result, linkPeer->peer());
|
||||
// }
|
||||
} else if (!request.overSelection && view && !hasSelection) {
|
||||
const auto owner = &view->data()->history()->owner();
|
||||
const auto media = view->media();
|
||||
const auto mediaHasTextForCopy = media && media->hasTextForCopy();
|
||||
if (const auto document = media ? media->getDocument() : nullptr) {
|
||||
|
@ -493,9 +497,9 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
|
|||
if (!link && (view->hasVisibleText() || mediaHasTextForCopy)) {
|
||||
const auto asGroup = (request.pointState != PointState::GroupPart);
|
||||
result->addAction(tr::lng_context_copy_text(tr::now), [=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (asGroup) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = owner->groups().find(item)) {
|
||||
SetClipboardText(HistoryGroupText(group));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -245,25 +245,25 @@ ListWidget::ListWidget(
|
|||
, _highlightTimer([this] { updateHighlightedMessage(); }) {
|
||||
setMouseTracking(true);
|
||||
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
|
||||
Auth().data().viewRepaintRequest(
|
||||
session().data().viewRepaintRequest(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
repaintItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().viewResizeRequest(
|
||||
session().data().viewResizeRequest(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
resizeItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().itemViewRefreshRequest(
|
||||
session().data().itemViewRefreshRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
refreshItem(view);
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().viewLayoutChanged(
|
||||
session().data().viewLayoutChanged(
|
||||
) | rpl::start_with_next([this](auto view) {
|
||||
if (view->delegate() == this) {
|
||||
if (view->isUnderCursor()) {
|
||||
|
@ -271,7 +271,7 @@ ListWidget::ListWidget(
|
|||
}
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().animationPlayInlineRequest(
|
||||
session().data().animationPlayInlineRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
if (const auto media = view->media()) {
|
||||
|
@ -279,11 +279,11 @@ ListWidget::ListWidget(
|
|||
}
|
||||
}
|
||||
}, lifetime());
|
||||
Auth().data().itemRemoved(
|
||||
session().data().itemRemoved(
|
||||
) | rpl::start_with_next(
|
||||
[this](auto item) { itemRemoved(item); },
|
||||
lifetime());
|
||||
subscribe(Auth().data().queryItemVisibility(), [this](const Data::Session::ItemVisibilityQuery &query) {
|
||||
subscribe(session().data().queryItemVisibility(), [this](const Data::Session::ItemVisibilityQuery &query) {
|
||||
if (const auto view = viewForItem(query.item)) {
|
||||
const auto top = itemTop(view);
|
||||
if (top >= 0
|
||||
|
@ -295,6 +295,10 @@ ListWidget::ListWidget(
|
|||
});
|
||||
}
|
||||
|
||||
AuthSession &ListWidget::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
not_null<ListDelegate*> ListWidget::delegate() const {
|
||||
return _delegate;
|
||||
}
|
||||
|
@ -317,7 +321,7 @@ void ListWidget::refreshRows() {
|
|||
_items.clear();
|
||||
_items.reserve(_slice.ids.size());
|
||||
for (const auto &fullId : _slice.ids) {
|
||||
if (const auto item = Auth().data().message(fullId)) {
|
||||
if (const auto item = session().data().message(fullId)) {
|
||||
_items.push_back(enforceViewForItem(item));
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +354,7 @@ std::optional<int> ListWidget::scrollTopForPosition(
|
|||
std::optional<int> ListWidget::scrollTopForView(
|
||||
not_null<Element*> view) const {
|
||||
if (view->isHiddenByGroup()) {
|
||||
if (const auto group = Auth().data().groups().find(view->data())) {
|
||||
if (const auto group = session().data().groups().find(view->data())) {
|
||||
if (const auto leader = viewForItem(group->items.back())) {
|
||||
if (!leader->isHiddenByGroup()) {
|
||||
return scrollTopForView(leader);
|
||||
|
@ -398,7 +402,7 @@ void ListWidget::animatedScrollTo(
|
|||
void ListWidget::scrollToAnimationCallback(
|
||||
FullMsgId attachToId,
|
||||
int relativeTo) {
|
||||
const auto attachTo = Auth().data().message(attachToId);
|
||||
const auto attachTo = session().data().message(attachToId);
|
||||
const auto attachToView = viewForItem(attachTo);
|
||||
if (!attachToView) {
|
||||
_scrollToAnimation.stop();
|
||||
|
@ -424,7 +428,7 @@ bool ListWidget::isBelowPosition(Data::MessagePosition position) const {
|
|||
}
|
||||
|
||||
void ListWidget::highlightMessage(FullMsgId itemId) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
_highlightStart = crl::now();
|
||||
_highlightedMessageId = itemId;
|
||||
|
@ -436,7 +440,7 @@ void ListWidget::highlightMessage(FullMsgId itemId) {
|
|||
}
|
||||
|
||||
void ListWidget::updateHighlightedMessage() {
|
||||
if (const auto item = Auth().data().message(_highlightedMessageId)) {
|
||||
if (const auto item = session().data().message(_highlightedMessageId)) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
repaintItem(view);
|
||||
auto duration = st::activeFadeInDuration + st::activeFadeOutDuration;
|
||||
|
@ -488,7 +492,7 @@ void ListWidget::restoreScrollState() {
|
|||
}
|
||||
|
||||
Element *ListWidget::viewForItem(FullMsgId itemId) const {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
return viewForItem(item);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -736,7 +740,7 @@ bool ListWidget::isSelectedGroup(
|
|||
bool ListWidget::isSelectedAsGroup(
|
||||
const SelectedMap &applyTo,
|
||||
not_null<HistoryItem*> item) const {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
return isSelectedGroup(applyTo, group);
|
||||
}
|
||||
return applyTo.contains(item->fullId());
|
||||
|
@ -803,7 +807,7 @@ void ListWidget::changeSelectionAsGroup(
|
|||
SelectedMap &applyTo,
|
||||
not_null<HistoryItem*> item,
|
||||
SelectAction action) const {
|
||||
const auto group = Auth().data().groups().find(item);
|
||||
const auto group = session().data().groups().find(item);
|
||||
if (!group) {
|
||||
return changeSelection(applyTo, item, action);
|
||||
}
|
||||
|
@ -1228,7 +1232,7 @@ TextSelection ListWidget::computeRenderSelection(
|
|||
return TextSelection();
|
||||
};
|
||||
const auto item = view->data();
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
if (group->items.back() != item) {
|
||||
return TextSelection();
|
||||
}
|
||||
|
@ -1393,7 +1397,7 @@ void ListWidget::applyDragSelection(SelectedMap &applyTo) const {
|
|||
if (applyTo.size() >= MaxSelectedItems) {
|
||||
break;
|
||||
} else if (!applyTo.contains(itemId)) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
addToSelection(applyTo, item);
|
||||
}
|
||||
}
|
||||
|
@ -1451,8 +1455,8 @@ TextForMimeData ListWidget::getSelectedText() const {
|
|||
};
|
||||
|
||||
for (const auto [itemId, data] : selected) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto group = Auth().data().groups().find(item)) {
|
||||
if (const auto item = session().data().message(itemId)) {
|
||||
if (const auto group = session().data().groups().find(item)) {
|
||||
if (groups.contains(group)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1694,7 +1698,7 @@ void ListWidget::updateDragSelection() {
|
|||
} else if (_items.empty() || !_overElement || !_selectEnabled) {
|
||||
return;
|
||||
}
|
||||
const auto pressItem = Auth().data().message(_pressState.itemId);
|
||||
const auto pressItem = session().data().message(_pressState.itemId);
|
||||
if (!pressItem) {
|
||||
return;
|
||||
}
|
||||
|
@ -1792,7 +1796,7 @@ void ListWidget::updateDragSelection(
|
|||
std::vector<not_null<Element*>>::const_iterator till) {
|
||||
Expects(from < till);
|
||||
|
||||
const auto &groups = Auth().data().groups();
|
||||
const auto &groups = session().data().groups();
|
||||
const auto changeItem = [&](not_null<HistoryItem*> item, bool add) {
|
||||
const auto itemId = item->fullId();
|
||||
if (add) {
|
||||
|
@ -2011,7 +2015,7 @@ void ListWidget::mouseActionFinish(
|
|||
return;
|
||||
}
|
||||
if (needItemSelectionToggle) {
|
||||
if (const auto item = Auth().data().message(pressState.itemId)) {
|
||||
if (const auto item = session().data().message(pressState.itemId)) {
|
||||
clearTextSelection();
|
||||
if (pressState.pointState == PointState::GroupPart) {
|
||||
changeSelection(
|
||||
|
@ -2144,7 +2148,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
dragState = TextState(
|
||||
nullptr,
|
||||
_scrollDateLink);
|
||||
_overItemExact = Auth().data().message(dragState.itemId);
|
||||
_overItemExact = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
}
|
||||
}
|
||||
|
@ -2154,7 +2158,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
});
|
||||
if (!dragState.link) {
|
||||
dragState = view->textState(itemPoint, request);
|
||||
_overItemExact = Auth().data().message(dragState.itemId);
|
||||
_overItemExact = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
if (!dragState.link
|
||||
&& itemPoint.x() >= st::historyPhotoLeft
|
||||
|
@ -2175,7 +2179,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
dragState = TextState(nullptr, from
|
||||
? from->openLink()
|
||||
: hiddenUserpicLink(message->fullId()));
|
||||
_overItemExact = Auth().data().message(dragState.itemId);
|
||||
_overItemExact = session().data().message(dragState.itemId);
|
||||
lnkhost = view;
|
||||
return false;
|
||||
}
|
||||
|
@ -2231,7 +2235,7 @@ void ListWidget::mouseActionUpdate() {
|
|||
// Voice message seek support.
|
||||
if (_pressState.pointState != PointState::Outside
|
||||
&& ClickHandler::getPressed()) {
|
||||
if (const auto item = Auth().data().message(_pressState.itemId)) {
|
||||
if (const auto item = session().data().message(_pressState.itemId)) {
|
||||
if (const auto view = viewForItem(item)) {
|
||||
auto adjustedPoint = mapPointToItem(point, view);
|
||||
view->updatePressed(adjustedPoint);
|
||||
|
@ -2272,7 +2276,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const auto pressedItem = Auth().data().message(_pressState.itemId);
|
||||
const auto pressedItem = session().data().message(_pressState.itemId);
|
||||
const auto pressedView = viewForItem(pressedItem);
|
||||
const auto uponSelected = pressedView && isInsideSelection(
|
||||
pressedView,
|
||||
|
@ -2311,7 +2315,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||
? getSelectedItems()
|
||||
: MessageIdsList();
|
||||
if (!items.empty()) {
|
||||
Auth().data().setMimeForwardIds(std::move(items));
|
||||
session().data().setMimeForwardIds(std::move(items));
|
||||
mimeData->setData(qsl("application/x-td-forward"), "1");
|
||||
}
|
||||
}
|
||||
|
@ -2322,7 +2326,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||
? _pressItemExact
|
||||
: pressedItem;
|
||||
if (_mouseCursorState == CursorState::Date) {
|
||||
forwardIds = Auth().data().itemOrItsGroup(_overElement->data());
|
||||
forwardIds = session().data().itemOrItsGroup(_overElement->data());
|
||||
} else if (_pressState.pointState == PointState::GroupPart) {
|
||||
forwardIds = MessageIdsList(1, exactItem->fullId());
|
||||
} else if (const auto media = pressedView->media()) {
|
||||
|
@ -2334,7 +2338,7 @@ std::unique_ptr<QMimeData> ListWidget::prepareDrag() {
|
|||
if (forwardIds.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
Auth().data().setMimeForwardIds(std::move(forwardIds));
|
||||
session().data().setMimeForwardIds(std::move(forwardIds));
|
||||
auto result = std::make_unique<QMimeData>();
|
||||
result->setData(qsl("application/x-td-forward"), "1");
|
||||
if (const auto media = pressedView->media()) {
|
||||
|
|
|
@ -15,6 +15,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_messages.h"
|
||||
#include "history/view/history_view_element.h"
|
||||
|
||||
class AuthSession;
|
||||
|
||||
namespace Ui {
|
||||
class PopupMenu;
|
||||
} // namespace Ui
|
||||
|
@ -128,6 +130,8 @@ public:
|
|||
not_null<Window::SessionController*> controller,
|
||||
not_null<ListDelegate*> delegate);
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
not_null<ListDelegate*> delegate() const;
|
||||
|
||||
// Set the correct scroll position after being resized.
|
||||
|
|
|
@ -1457,12 +1457,13 @@ void Message::drawRightAction(
|
|||
|
||||
ClickHandlerPtr Message::rightActionLink() const {
|
||||
if (!_rightActionLink) {
|
||||
const auto owner = &data()->history()->owner();
|
||||
const auto itemId = data()->fullId();
|
||||
const auto forwarded = data()->Get<HistoryMessageForwarded>();
|
||||
const auto savedFromPeer = forwarded ? forwarded->savedFromPeer : nullptr;
|
||||
const auto savedFromMsgId = forwarded ? forwarded->savedFromMsgId : 0;
|
||||
_rightActionLink = std::make_shared<LambdaClickHandler>([=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (savedFromPeer && savedFromMsgId) {
|
||||
App::wnd()->sessionController()->showPeerHistory(
|
||||
savedFromPeer,
|
||||
|
@ -1479,9 +1480,10 @@ ClickHandlerPtr Message::rightActionLink() const {
|
|||
|
||||
ClickHandlerPtr Message::fastReplyLink() const {
|
||||
if (!_fastReplyLink) {
|
||||
const auto owner = &data()->history()->owner();
|
||||
const auto itemId = data()->fullId();
|
||||
_fastReplyLink = std::make_shared<LambdaClickHandler>([=] {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = owner->message(itemId)) {
|
||||
if (const auto main = App::main()) {
|
||||
main->replyToItem(item);
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ TopBarWidget::TopBarWidget(
|
|||
, _infoToggle(this, st::topBarInfo)
|
||||
, _menuToggle(this, st::topBarMenuToggle)
|
||||
, _titlePeerText(st::windowMinWidth / 3)
|
||||
, _onlineUpdater([this] { updateOnlineDisplay(); }) {
|
||||
, _onlineUpdater([=] { updateOnlineDisplay(); }) {
|
||||
subscribe(Lang::Current().updated(), [this] { refreshLang(); });
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
|
@ -100,7 +100,7 @@ TopBarWidget::TopBarWidget(
|
|||
refreshUnreadBadge();
|
||||
{
|
||||
using AnimationUpdate = Data::Session::SendActionAnimationUpdate;
|
||||
Auth().data().sendActionAnimationUpdated(
|
||||
session().data().sendActionAnimationUpdated(
|
||||
) | rpl::filter([=](const AnimationUpdate &update) {
|
||||
return (update.history == _activeChat.history());
|
||||
}) | rpl::start_with_next([=] {
|
||||
|
@ -127,8 +127,8 @@ TopBarWidget::TopBarWidget(
|
|||
});
|
||||
|
||||
rpl::combine(
|
||||
Auth().settings().thirdSectionInfoEnabledValue(),
|
||||
Auth().settings().tabbedReplacedWithInfoValue()
|
||||
session().settings().thirdSectionInfoEnabledValue(),
|
||||
session().settings().tabbedReplacedWithInfoValue()
|
||||
) | rpl::start_with_next(
|
||||
[this] { updateInfoToggleActive(); },
|
||||
lifetime());
|
||||
|
@ -143,6 +143,12 @@ TopBarWidget::TopBarWidget(
|
|||
updateControlsVisibility();
|
||||
}
|
||||
|
||||
TopBarWidget::~TopBarWidget() = default;
|
||||
|
||||
AuthSession &TopBarWidget::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void TopBarWidget::updateConnectingState() {
|
||||
const auto mtp = MTP::dcstate();
|
||||
if (mtp == MTP::ConnectedState) {
|
||||
|
@ -236,13 +242,13 @@ void TopBarWidget::showMenu() {
|
|||
|
||||
void TopBarWidget::toggleInfoSection() {
|
||||
if (Adaptive::ThreeColumn()
|
||||
&& (Auth().settings().thirdSectionInfoEnabled()
|
||||
|| Auth().settings().tabbedReplacedWithInfo())) {
|
||||
&& (session().settings().thirdSectionInfoEnabled()
|
||||
|| session().settings().tabbedReplacedWithInfo())) {
|
||||
_controller->closeThirdSection();
|
||||
} else if (_activeChat.peer()) {
|
||||
if (_controller->canShowThirdSection()) {
|
||||
Auth().settings().setThirdSectionInfoEnabled(true);
|
||||
Auth().saveSettingsDelayed();
|
||||
session().settings().setThirdSectionInfoEnabled(true);
|
||||
session().saveSettingsDelayed();
|
||||
if (Adaptive::ThreeColumn()) {
|
||||
_controller->showSection(
|
||||
Info::Memento::Default(_activeChat.peer()),
|
||||
|
@ -745,8 +751,8 @@ void TopBarWidget::refreshUnreadBadge() {
|
|||
void TopBarWidget::updateUnreadBadge() {
|
||||
if (!_unreadBadge) return;
|
||||
|
||||
const auto muted = Auth().data().unreadBadgeMutedIgnoreOne(_activeChat);
|
||||
const auto counter = Auth().data().unreadBadgeIgnoreOne(_activeChat);
|
||||
const auto muted = session().data().unreadBadgeMutedIgnoreOne(_activeChat);
|
||||
const auto counter = session().data().unreadBadgeIgnoreOne(_activeChat);
|
||||
const auto text = [&] {
|
||||
if (!counter) {
|
||||
return QString();
|
||||
|
@ -760,8 +766,8 @@ void TopBarWidget::updateUnreadBadge() {
|
|||
|
||||
void TopBarWidget::updateInfoToggleActive() {
|
||||
auto infoThirdActive = Adaptive::ThreeColumn()
|
||||
&& (Auth().settings().thirdSectionInfoEnabled()
|
||||
|| Auth().settings().tabbedReplacedWithInfo());
|
||||
&& (session().settings().thirdSectionInfoEnabled()
|
||||
|| session().settings().tabbedReplacedWithInfo());
|
||||
auto iconOverride = infoThirdActive
|
||||
? &st::topBarInfoActive
|
||||
: nullptr;
|
||||
|
@ -779,8 +785,8 @@ void TopBarWidget::updateOnlineDisplay() {
|
|||
const auto now = base::unixtime::now();
|
||||
bool titlePeerTextOnline = false;
|
||||
if (const auto user = _activeChat.peer()->asUser()) {
|
||||
if (Auth().supportMode()
|
||||
&& !Auth().supportHelper().infoCurrent(user).text.empty()) {
|
||||
if (session().supportMode()
|
||||
&& !session().supportHelper().infoCurrent(user).text.empty()) {
|
||||
text = QString::fromUtf8("\xe2\x9a\xa0\xef\xb8\x8f check info");
|
||||
titlePeerTextOnline = false;
|
||||
} else {
|
||||
|
@ -799,7 +805,7 @@ void TopBarWidget::updateOnlineDisplay() {
|
|||
text = tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count);
|
||||
}
|
||||
} else {
|
||||
const auto self = Auth().user();
|
||||
const auto self = session().user();
|
||||
auto online = 0;
|
||||
auto onlyMe = true;
|
||||
for (const auto user : chat->participants) {
|
||||
|
@ -821,9 +827,9 @@ void TopBarWidget::updateOnlineDisplay() {
|
|||
} else if (const auto channel = _activeChat.peer()->asChannel()) {
|
||||
if (channel->isMegagroup() && channel->membersCount() > 0 && channel->membersCount() <= Global::ChatSizeMax()) {
|
||||
if (channel->mgInfo->lastParticipants.empty() || channel->lastParticipantsCountOutdated()) {
|
||||
Auth().api().requestLastParticipants(channel);
|
||||
session().api().requestLastParticipants(channel);
|
||||
}
|
||||
const auto self = Auth().user();
|
||||
const auto self = session().user();
|
||||
auto online = 0;
|
||||
auto onlyMe = true;
|
||||
for (auto &participant : std::as_const(channel->mgInfo->lastParticipants)) {
|
||||
|
@ -883,6 +889,4 @@ void TopBarWidget::updateOnlineDisplayIn(crl::time timeout) {
|
|||
_onlineUpdater.callOnce(timeout);
|
||||
}
|
||||
|
||||
TopBarWidget::~TopBarWidget() = default;
|
||||
|
||||
} // namespace HistoryView
|
||||
|
|
|
@ -12,6 +12,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/timer.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
|
||||
class AuthSession;
|
||||
|
||||
namespace Ui {
|
||||
class AbstractButton;
|
||||
class RoundButton;
|
||||
|
@ -29,10 +31,6 @@ namespace HistoryView {
|
|||
|
||||
class TopBarWidget : public Ui::RpWidget, private base::Subscriber {
|
||||
public:
|
||||
TopBarWidget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller);
|
||||
|
||||
struct SelectedState {
|
||||
bool textSelected = false;
|
||||
int count = 0;
|
||||
|
@ -40,8 +38,13 @@ public:
|
|||
int canForwardCount = 0;
|
||||
};
|
||||
|
||||
TopBarWidget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller);
|
||||
~TopBarWidget();
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
void updateControlsVisibility();
|
||||
void finishAnimating();
|
||||
void showSelected(SelectedState state);
|
||||
|
|
|
@ -554,6 +554,10 @@ ListWidget::ListWidget(
|
|||
start();
|
||||
}
|
||||
|
||||
AuthSession &ListWidget::session() const {
|
||||
return _controller->session();
|
||||
}
|
||||
|
||||
void ListWidget::start() {
|
||||
_controller->setSearchEnabledByContent(false);
|
||||
ObservableViewer(
|
||||
|
@ -564,17 +568,17 @@ void ListWidget::start() {
|
|||
}
|
||||
}, lifetime());
|
||||
ObservableViewer(
|
||||
Auth().downloader().taskFinished()
|
||||
session().downloader().taskFinished()
|
||||
) | rpl::start_with_next([this] { update(); }, lifetime());
|
||||
Auth().data().itemLayoutChanged(
|
||||
session().data().itemLayoutChanged(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
itemLayoutChanged(item);
|
||||
}, lifetime());
|
||||
Auth().data().itemRemoved(
|
||||
session().data().itemRemoved(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
itemRemoved(item);
|
||||
}, lifetime());
|
||||
Auth().data().itemRepaintRequest(
|
||||
session().data().itemRepaintRequest(
|
||||
) | rpl::start_with_next([this](auto item) {
|
||||
repaintItem(item);
|
||||
}, lifetime());
|
||||
|
@ -839,7 +843,7 @@ BaseLayout *ListWidget::getExistingLayout(
|
|||
std::unique_ptr<BaseLayout> ListWidget::createLayout(
|
||||
UniversalMsgId universalId,
|
||||
Type type) {
|
||||
auto item = Auth().data().message(computeFullId(universalId));
|
||||
auto item = session().data().message(computeFullId(universalId));
|
||||
if (!item) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1180,7 +1184,7 @@ void ListWidget::showContextMenu(
|
|||
mouseActionUpdate(e->globalPos());
|
||||
}
|
||||
|
||||
auto item = Auth().data().message(computeFullId(_overState.itemId));
|
||||
auto item = session().data().message(computeFullId(_overState.itemId));
|
||||
if (!item || !_overState.inside) {
|
||||
return;
|
||||
}
|
||||
|
@ -1225,11 +1229,12 @@ void ListWidget::showContextMenu(
|
|||
auto link = ClickHandler::getActive();
|
||||
|
||||
const auto itemFullId = item->fullId();
|
||||
const auto owner = &session().data();
|
||||
_contextMenu = base::make_unique_q<Ui::PopupMenu>(this);
|
||||
_contextMenu->addAction(
|
||||
tr::lng_context_to_msg(tr::now),
|
||||
[itemFullId] {
|
||||
if (auto item = Auth().data().message(itemFullId)) {
|
||||
[=] {
|
||||
if (const auto item = owner->message(itemFullId)) {
|
||||
Ui::showPeerHistoryAtItem(item);
|
||||
}
|
||||
});
|
||||
|
@ -1381,7 +1386,7 @@ void ListWidget::forwardSelected() {
|
|||
}
|
||||
|
||||
void ListWidget::forwardItem(UniversalMsgId universalId) {
|
||||
if (const auto item = Auth().data().message(computeFullId(universalId))) {
|
||||
if (const auto item = session().data().message(computeFullId(universalId))) {
|
||||
forwardItems({ 1, item->fullId() });
|
||||
}
|
||||
}
|
||||
|
@ -1409,7 +1414,7 @@ void ListWidget::deleteSelected() {
|
|||
}
|
||||
|
||||
void ListWidget::deleteItem(UniversalMsgId universalId) {
|
||||
if (const auto item = Auth().data().message(computeFullId(universalId))) {
|
||||
if (const auto item = session().data().message(computeFullId(universalId))) {
|
||||
deleteItems({ 1, item->fullId() });
|
||||
}
|
||||
}
|
||||
|
@ -1513,7 +1518,7 @@ bool ListWidget::changeItemSelection(
|
|||
universalId,
|
||||
selection);
|
||||
if (ok) {
|
||||
auto item = Auth().data().message(computeFullId(universalId));
|
||||
auto item = session().data().message(computeFullId(universalId));
|
||||
if (!item) {
|
||||
selected.erase(iterator);
|
||||
return false;
|
||||
|
@ -1932,7 +1937,7 @@ void ListWidget::performDrag() {
|
|||
// if (uponSelected && !Adaptive::OneColumn()) {
|
||||
// auto selectedState = getSelectionState();
|
||||
// if (selectedState.count > 0 && selectedState.count == selectedState.canForwardCount) {
|
||||
// Auth().data().setMimeForwardIds(collectSelectedIds());
|
||||
// session().data().setMimeForwardIds(collectSelectedIds());
|
||||
// mimeData->setData(qsl("application/x-td-forward"), "1");
|
||||
// }
|
||||
// }
|
||||
|
@ -1944,14 +1949,14 @@ void ListWidget::performDrag() {
|
|||
// if (auto pressedItem = _pressState.layout) {
|
||||
// pressedMedia = pressedItem->getMedia();
|
||||
// if (_mouseCursorState == CursorState::Date || (pressedMedia && pressedMedia->dragItem())) {
|
||||
// Auth().data().setMimeForwardIds(Auth().data().itemOrItsGroup(pressedItem));
|
||||
// session().data().setMimeForwardIds(session().data().itemOrItsGroup(pressedItem));
|
||||
// forwardMimeType = qsl("application/x-td-forward");
|
||||
// }
|
||||
// }
|
||||
// if (auto pressedLnkItem = App::pressedLinkItem()) {
|
||||
// if ((pressedMedia = pressedLnkItem->getMedia())) {
|
||||
// if (forwardMimeType.isEmpty() && pressedMedia->dragItemByHandler(pressedHandler)) {
|
||||
// Auth().data().setMimeForwardIds({ 1, pressedLnkItem->fullId() });
|
||||
// session().data().setMimeForwardIds({ 1, pressedLnkItem->fullId() });
|
||||
// forwardMimeType = qsl("application/x-td-forward");
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_shared_media.h"
|
||||
|
||||
class DeleteMessagesBox;
|
||||
class AuthSession;
|
||||
|
||||
namespace HistoryView {
|
||||
struct TextState;
|
||||
|
@ -49,6 +50,8 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<AbstractController*> controller);
|
||||
|
||||
AuthSession &session() const;
|
||||
|
||||
void restart();
|
||||
|
||||
rpl::producer<int> scrollToRequests() const;
|
||||
|
|
|
@ -351,10 +351,10 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
|||
result->toggleOn(
|
||||
NotificationsEnabledValue(peer)
|
||||
)->addClickHandler([=] {
|
||||
const auto muteForSeconds = Auth().data().notifyIsMuted(peer)
|
||||
const auto muteForSeconds = peer->owner().notifyIsMuted(peer)
|
||||
? 0
|
||||
: Data::NotifySettings::kDefaultMutePeriod;
|
||||
Auth().data().updateNotifySettings(peer, muteForSeconds);
|
||||
peer->owner().updateNotifySettings(peer, muteForSeconds);
|
||||
});
|
||||
object_ptr<FloatingIcon>(
|
||||
result,
|
||||
|
@ -653,7 +653,7 @@ void ActionsFiller::addJoinChannelAction(
|
|||
_wrap,
|
||||
tr::lng_profile_join_channel(),
|
||||
rpl::duplicate(joinVisible),
|
||||
[channel] { Auth().api().joinChannel(channel); });
|
||||
[=] { channel->session().api().joinChannel(channel); });
|
||||
_wrap->add(object_ptr<Ui::SlideWrap<Ui::FixedHeightWidget>>(
|
||||
_wrap,
|
||||
CreateSkipWidget(
|
||||
|
@ -749,19 +749,20 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
|
|||
//
|
||||
//object_ptr<Ui::RpWidget> FeedDetailsFiller::setupDefaultToggle() {
|
||||
// using namespace rpl::mappers;
|
||||
// const auto feedId = _feed->id();
|
||||
// const auto feed = _feed;
|
||||
// const auto feedId = feed->id();
|
||||
// auto result = object_ptr<Button>(
|
||||
// _wrap,
|
||||
// tr::lng_info_feed_is_default(),
|
||||
// st::infoNotificationsButton);
|
||||
// result->toggleOn(
|
||||
// Auth().data().defaultFeedIdValue(
|
||||
// feed->owner().defaultFeedIdValue(
|
||||
// ) | rpl::map(_1 == feedId)
|
||||
// )->addClickHandler([=] {
|
||||
// const auto makeDefault = (Auth().data().defaultFeedId() != feedId);
|
||||
// const auto makeDefault = (feed->owner().defaultFeedId() != feedId);
|
||||
// const auto defaultFeedId = makeDefault ? feedId : 0;
|
||||
// Auth().data().setDefaultFeedId(defaultFeedId);
|
||||
//// Auth().api().saveDefaultFeedId(feedId, makeDefault); // #feed
|
||||
// feed->owner().setDefaultFeedId(defaultFeedId);
|
||||
//// feed->session().api().saveDefaultFeedId(feedId, makeDefault); // #feed
|
||||
// });
|
||||
// object_ptr<FloatingIcon>(
|
||||
// result,
|
||||
|
|
|
@ -590,7 +590,9 @@ void MainWindow::onShowAddContact() {
|
|||
if (isHidden()) showFromTray();
|
||||
|
||||
if (account().sessionExists()) {
|
||||
Ui::show(Box<AddContactBox>(), LayerOption::KeepOther);
|
||||
Ui::show(
|
||||
Box<AddContactBox>(&account().session()),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +601,9 @@ void MainWindow::onShowNewGroup() {
|
|||
|
||||
if (account().sessionExists()) {
|
||||
Ui::show(
|
||||
Box<GroupInfoBox>(GroupInfoBox::Type::Group),
|
||||
Box<GroupInfoBox>(
|
||||
&account().session(),
|
||||
GroupInfoBox::Type::Group),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +613,9 @@ void MainWindow::onShowNewChannel() {
|
|||
|
||||
if (_main) {
|
||||
Ui::show(
|
||||
Box<GroupInfoBox>(GroupInfoBox::Type::Channel),
|
||||
Box<GroupInfoBox>(
|
||||
&account().session(),
|
||||
GroupInfoBox::Type::Channel),
|
||||
LayerOption::KeepOther);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/localstorage.h"
|
||||
#include "auth_session.h"
|
||||
#include "apiwrap.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "core/file_utilities.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
|
@ -297,8 +298,8 @@ void Main::setupContent(not_null<Window::SessionController*> controller) {
|
|||
Ui::ResizeFitChild(this, content);
|
||||
|
||||
// If we load this in advance it won't jump when we open its' section.
|
||||
Auth().api().reloadPasswordState();
|
||||
Auth().api().reloadContactSignupSilent();
|
||||
controller->session().api().reloadPasswordState();
|
||||
controller->session().api().reloadContactSignupSilent();
|
||||
}
|
||||
|
||||
rpl::producer<Type> Main::sectionShowOther() {
|
||||
|
|
|
@ -584,7 +584,7 @@ void UserpicButton::changePhotoLazy() {
|
|||
|
||||
void UserpicButton::uploadNewPeerPhoto() {
|
||||
auto callback = crl::guard(this, [=](QImage &&image) {
|
||||
Auth().api().uploadPeerPhoto(_peer, std::move(image));
|
||||
_peer->session().api().uploadPeerPhoto(_peer, std::move(image));
|
||||
});
|
||||
ShowChoosePhotoBox(this, _cropTitle, std::move(callback));
|
||||
}
|
||||
|
@ -602,7 +602,7 @@ void UserpicButton::openPeerPhoto() {
|
|||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const auto photo = Auth().data().photo(id);
|
||||
const auto photo = _peer->owner().photo(id);
|
||||
if (photo->date) {
|
||||
Core::App().showPhoto(photo, _peer);
|
||||
}
|
||||
|
@ -616,8 +616,9 @@ void UserpicButton::setupPeerViewers() {
|
|||
processNewPeerPhoto();
|
||||
update();
|
||||
}, lifetime());
|
||||
|
||||
base::ObservableViewer(
|
||||
Auth().downloaderTaskFinished()
|
||||
_peer->session().downloaderTaskFinished()
|
||||
) | rpl::start_with_next([this] {
|
||||
if (_waiting && _peer->userpicLoaded()) {
|
||||
_waiting = false;
|
||||
|
@ -958,7 +959,7 @@ void UserpicButton::prepareUserpicPixmap() {
|
|||
//void FeedUserpicButton::prepare() {
|
||||
// resize(_st.size);
|
||||
//
|
||||
// Auth().data().feedUpdated(
|
||||
// _feed->owner().feedUpdated(
|
||||
// ) | rpl::filter([=](const Data::FeedUpdate &update) {
|
||||
// return (update.feed == _feed)
|
||||
// && (update.flag == Data::FeedUpdateFlag::Channels);
|
||||
|
@ -1035,8 +1036,8 @@ void UserpicButton::prepareUserpicPixmap() {
|
|||
SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
|
||||
: IconButton(parent, st::historySilentToggle)
|
||||
, _channel(channel)
|
||||
, _checked(Auth().data().notifySilentPosts(_channel)) {
|
||||
Expects(!Auth().data().notifySilentPostsUnknown(_channel));
|
||||
, _checked(channel->owner().notifySilentPosts(_channel)) {
|
||||
Expects(!channel->owner().notifySilentPostsUnknown(_channel));
|
||||
|
||||
if (_checked) {
|
||||
refreshIconOverrides();
|
||||
|
@ -1079,7 +1080,7 @@ void SilentToggle::mouseReleaseEvent(QMouseEvent *e) {
|
|||
setChecked(!_checked);
|
||||
IconButton::mouseReleaseEvent(e);
|
||||
Ui::Tooltip::Show(0, this);
|
||||
Auth().data().updateNotifySettings(
|
||||
_channel->owner().updateNotifySettings(
|
||||
_channel,
|
||||
std::nullopt,
|
||||
_checked);
|
||||
|
|
|
@ -861,7 +861,9 @@ MediaPreviewWidget::MediaPreviewWidget(
|
|||
, _controller(controller)
|
||||
, _emojiSize(Ui::Emoji::GetSizeLarge() / cIntRetinaFactor()) {
|
||||
setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
|
||||
subscribe(_controller->session().downloaderTaskFinished(), [=] {
|
||||
update();
|
||||
});
|
||||
}
|
||||
|
||||
QRect MediaPreviewWidget::updateArea() const {
|
||||
|
|
|
@ -61,7 +61,9 @@ void System::createManager() {
|
|||
}
|
||||
}
|
||||
|
||||
void System::schedule(History *history, HistoryItem *item) {
|
||||
void System::schedule(
|
||||
not_null<History*> history,
|
||||
not_null<HistoryItem*> item) {
|
||||
if (App::quitting()
|
||||
|| !history->currentNotification()
|
||||
|| !AuthSession::Exists()) return;
|
||||
|
@ -75,16 +77,16 @@ void System::schedule(History *history, HistoryItem *item) {
|
|||
return;
|
||||
}
|
||||
|
||||
Auth().data().requestNotifySettings(history->peer);
|
||||
history->owner().requestNotifySettings(history->peer);
|
||||
if (notifyBy) {
|
||||
Auth().data().requestNotifySettings(notifyBy);
|
||||
history->owner().requestNotifySettings(notifyBy);
|
||||
}
|
||||
auto haveSetting = !Auth().data().notifyMuteUnknown(history->peer);
|
||||
if (haveSetting && Auth().data().notifyIsMuted(history->peer)) {
|
||||
auto haveSetting = !history->owner().notifyMuteUnknown(history->peer);
|
||||
if (haveSetting && history->owner().notifyIsMuted(history->peer)) {
|
||||
if (notifyBy) {
|
||||
haveSetting = !Auth().data().notifyMuteUnknown(notifyBy);
|
||||
haveSetting = !history->owner().notifyMuteUnknown(notifyBy);
|
||||
if (haveSetting) {
|
||||
if (Auth().data().notifyIsMuted(notifyBy)) {
|
||||
if (history->owner().notifyIsMuted(notifyBy)) {
|
||||
history->popNotification(item);
|
||||
return;
|
||||
}
|
||||
|
@ -174,12 +176,12 @@ void System::checkDelayed() {
|
|||
const auto peer = history->peer;
|
||||
auto loaded = false;
|
||||
auto muted = false;
|
||||
if (!Auth().data().notifyMuteUnknown(peer)) {
|
||||
if (!Auth().data().notifyIsMuted(peer)) {
|
||||
if (!peer->owner().notifyMuteUnknown(peer)) {
|
||||
if (!peer->owner().notifyIsMuted(peer)) {
|
||||
loaded = true;
|
||||
} else if (const auto from = i.value().notifyBy) {
|
||||
if (!Auth().data().notifyMuteUnknown(from)) {
|
||||
if (!Auth().data().notifyIsMuted(from)) {
|
||||
if (!peer->owner().notifyMuteUnknown(from)) {
|
||||
if (!peer->owner().notifyIsMuted(from)) {
|
||||
loaded = true;
|
||||
} else {
|
||||
loaded = muted = true;
|
||||
|
@ -193,7 +195,7 @@ void System::checkDelayed() {
|
|||
const auto fullId = FullMsgId(
|
||||
history->channelId(),
|
||||
i.value().msg);
|
||||
if (const auto item = Auth().data().message(fullId)) {
|
||||
if (const auto item = peer->owner().message(fullId)) {
|
||||
if (!item->notificationReady()) {
|
||||
loaded = false;
|
||||
}
|
||||
|
@ -215,7 +217,7 @@ void System::checkDelayed() {
|
|||
}
|
||||
|
||||
void System::showGrouped() {
|
||||
if (const auto lastItem = Auth().data().message(_lastHistoryItemId)) {
|
||||
if (const auto lastItem = session().data().message(_lastHistoryItemId)) {
|
||||
_waitForAllGroupedTimer.cancel();
|
||||
_manager->showNotification(lastItem, _lastForwardedCount);
|
||||
_lastForwardedCount = 0;
|
||||
|
@ -230,7 +232,9 @@ void System::showNext() {
|
|||
if (!_lastHistoryItemId || !item) {
|
||||
return false;
|
||||
}
|
||||
if (const auto lastItem = Auth().data().message(_lastHistoryItemId)) {
|
||||
const auto lastItem = item->history()->owner().message(
|
||||
_lastHistoryItemId);
|
||||
if (lastItem) {
|
||||
return (lastItem->groupId() == item->groupId() || lastItem->author() == item->author());
|
||||
}
|
||||
return false;
|
||||
|
@ -242,14 +246,14 @@ void System::showNext() {
|
|||
for (auto i = _whenAlerts.begin(); i != _whenAlerts.end();) {
|
||||
while (!i.value().isEmpty() && i.value().begin().key() <= ms) {
|
||||
const auto peer = i.key()->peer;
|
||||
const auto peerUnknown = Auth().data().notifyMuteUnknown(peer);
|
||||
const auto peerUnknown = peer->owner().notifyMuteUnknown(peer);
|
||||
const auto peerAlert = !peerUnknown
|
||||
&& !Auth().data().notifyIsMuted(peer);
|
||||
&& !peer->owner().notifyIsMuted(peer);
|
||||
const auto from = i.value().begin().value();
|
||||
const auto fromUnknown = (!from
|
||||
|| Auth().data().notifyMuteUnknown(from));
|
||||
|| peer->owner().notifyMuteUnknown(from));
|
||||
const auto fromAlert = !fromUnknown
|
||||
&& !Auth().data().notifyIsMuted(from);
|
||||
&& !peer->owner().notifyIsMuted(from);
|
||||
if (peerAlert || fromAlert) {
|
||||
alert = true;
|
||||
}
|
||||
|
@ -432,7 +436,7 @@ void System::ensureSoundCreated() {
|
|||
|
||||
_soundTrack = Media::Audio::Current().createTrack();
|
||||
_soundTrack->fillFromFile(
|
||||
Auth().settings().getSoundPath(qsl("msg_incoming")));
|
||||
session().settings().getSoundPath(qsl("msg_incoming")));
|
||||
}
|
||||
|
||||
void System::updateAll() {
|
||||
|
@ -458,7 +462,7 @@ Manager::DisplayOptions Manager::getNotificationOptions(HistoryItem *item) {
|
|||
void Manager::notificationActivated(PeerId peerId, MsgId msgId) {
|
||||
onBeforeNotificationActivated(peerId, msgId);
|
||||
if (auto window = App::wnd()) {
|
||||
auto history = Auth().data().history(peerId);
|
||||
auto history = system()->session().data().history(peerId);
|
||||
window->showFromTray();
|
||||
window->reActivateWindow();
|
||||
if (Core::App().locked()) {
|
||||
|
@ -480,7 +484,7 @@ void Manager::openNotificationMessage(
|
|||
|| !IsServerMsgId(messageId)) {
|
||||
return false;
|
||||
}
|
||||
const auto item = Auth().data().message(history->channelId(), messageId);
|
||||
const auto item = history->owner().message(history->channelId(), messageId);
|
||||
if (!item || !item->mentionsMe()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -509,7 +513,7 @@ void Manager::notificationReplied(
|
|||
const TextWithTags &reply) {
|
||||
if (!peerId) return;
|
||||
|
||||
const auto history = Auth().data().history(peerId);
|
||||
const auto history = system()->session().data().history(peerId);
|
||||
|
||||
auto message = ApiWrap::MessageToSend(history);
|
||||
message.textWithTags = reply;
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
void createManager();
|
||||
|
||||
void checkDelayed();
|
||||
void schedule(History *history, HistoryItem *item);
|
||||
void schedule(not_null<History*> history, not_null<HistoryItem*> item);
|
||||
void clearFromHistory(History *history);
|
||||
void clearFromItem(HistoryItem *item);
|
||||
void clearAll();
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
|
||||
class Manager {
|
||||
public:
|
||||
Manager(System *system) : _system(system) {
|
||||
explicit Manager(not_null<System*> system) : _system(system) {
|
||||
}
|
||||
|
||||
void showNotification(HistoryItem *item, int forwardedCount) {
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
virtual ~Manager() = default;
|
||||
|
||||
protected:
|
||||
System *system() const {
|
||||
not_null<System*> system() const {
|
||||
return _system;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ private:
|
|||
not_null<History*> history,
|
||||
MsgId messageId);
|
||||
|
||||
System *_system = nullptr;
|
||||
const not_null<System*> _system;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -128,17 +128,22 @@ MainMenu::MainMenu(
|
|||
, _version(this, st::mainMenuVersionLabel) {
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
|
||||
const auto showSelfChat = [] {
|
||||
App::main()->choosePeer(Auth().userPeerId(), ShowAtUnreadMsgId);
|
||||
const auto showSelfChat = [=] {
|
||||
App::main()->choosePeer(
|
||||
_controller->session().userPeerId(),
|
||||
ShowAtUnreadMsgId);
|
||||
};
|
||||
const auto showArchive = [=] {
|
||||
if (const auto folder = Auth().data().folderLoaded(Data::Folder::kId)) {
|
||||
const auto folder = _controller->session().data().folderLoaded(
|
||||
Data::Folder::kId);
|
||||
if (folder) {
|
||||
App::wnd()->sessionController()->openFolder(folder);
|
||||
Ui::hideSettingsAndLayer();
|
||||
}
|
||||
};
|
||||
const auto checkArchive = [=] {
|
||||
const auto folder = Auth().data().folderLoaded(Data::Folder::kId);
|
||||
const auto folder = _controller->session().data().folderLoaded(
|
||||
Data::Folder::kId);
|
||||
return folder
|
||||
&& !folder->chatsList()->empty()
|
||||
&& _controller->session().settings().archiveInMainMenu();
|
||||
|
@ -146,7 +151,7 @@ MainMenu::MainMenu(
|
|||
_userpicButton.create(
|
||||
this,
|
||||
_controller,
|
||||
Auth().user(),
|
||||
_controller->session().user(),
|
||||
Ui::UserpicButton::Role::Custom,
|
||||
st::mainMenuUserpic);
|
||||
_userpicButton->setClickedCallback(showSelfChat);
|
||||
|
@ -201,8 +206,7 @@ MainMenu::MainMenu(
|
|||
_version->setLink(1, std::make_shared<UrlClickHandler>(qsl("https://desktop.telegram.org/changelog")));
|
||||
_version->setLink(2, std::make_shared<LambdaClickHandler>([] { Ui::show(Box<AboutBox>()); }));
|
||||
|
||||
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
|
||||
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
|
||||
subscribe(_controller->session().downloaderTaskFinished(), [=] { update(); });
|
||||
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserPhoneChanged, [this](const Notify::PeerUpdate &update) {
|
||||
if (update.peer->isSelf()) {
|
||||
updatePhone();
|
||||
|
@ -217,7 +221,7 @@ MainMenu::MainMenu(
|
|||
refreshBackground();
|
||||
}
|
||||
});
|
||||
Auth().data().chatsListChanges(
|
||||
_controller->session().data().chatsListChanges(
|
||||
) | rpl::filter([](Data::Folder *folder) {
|
||||
return folder && (folder->id() == Data::Folder::kId);
|
||||
}) | rpl::start_with_next([=](Data::Folder *folder) {
|
||||
|
@ -230,7 +234,7 @@ MainMenu::MainMenu(
|
|||
|
||||
void MainMenu::refreshMenu() {
|
||||
_menu->clearActions();
|
||||
if (!Auth().supportMode()) {
|
||||
if (!_controller->session().supportMode()) {
|
||||
_menu->addAction(tr::lng_create_group_title(tr::now), [] {
|
||||
App::wnd()->onShowNewGroup();
|
||||
}, &st::mainMenuNewGroup, &st::mainMenuNewGroupOver);
|
||||
|
@ -265,14 +269,16 @@ void MainMenu::refreshMenu() {
|
|||
const auto fix = std::make_shared<QPointer<QAction>>();
|
||||
*fix = _menu->addAction(qsl("Fix chats order"), [=] {
|
||||
(*fix)->setChecked(!(*fix)->isChecked());
|
||||
Auth().settings().setSupportFixChatsOrder((*fix)->isChecked());
|
||||
_controller->session().settings().setSupportFixChatsOrder(
|
||||
(*fix)->isChecked());
|
||||
Local::writeUserSettings();
|
||||
}, &st::mainMenuFixOrder, &st::mainMenuFixOrderOver);
|
||||
(*fix)->setCheckable(true);
|
||||
(*fix)->setChecked(Auth().settings().supportFixChatsOrder());
|
||||
(*fix)->setChecked(
|
||||
_controller->session().settings().supportFixChatsOrder());
|
||||
|
||||
_menu->addAction(qsl("Reload templates"), [=] {
|
||||
Auth().supportTemplates().reload();
|
||||
_controller->session().supportTemplates().reload();
|
||||
}, &st::mainMenuReload, &st::mainMenuReloadOver);
|
||||
}
|
||||
_menu->addAction(tr::lng_menu_settings(tr::now), [] {
|
||||
|
@ -335,7 +341,8 @@ void MainMenu::refreshBackground() {
|
|||
st::mainMenuCoverTextLeft,
|
||||
st::mainMenuCoverNameTop,
|
||||
std::max(
|
||||
st::semiboldFont->width(Auth().user()->nameText().toString()),
|
||||
st::semiboldFont->width(
|
||||
_controller->session().user()->nameText().toString()),
|
||||
st::normalFont->width(_phoneText)),
|
||||
st::semiboldFont->height * 2);
|
||||
|
||||
|
@ -376,7 +383,7 @@ void MainMenu::updateControlsGeometry() {
|
|||
}
|
||||
|
||||
void MainMenu::updatePhone() {
|
||||
_phoneText = App::formatPhone(Auth().user()->phone());
|
||||
_phoneText = App::formatPhone(_controller->session().user()->phone());
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -408,7 +415,7 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
|||
}
|
||||
p.setPen(st::mainMenuCoverFg);
|
||||
p.setFont(st::semiboldFont);
|
||||
Auth().user()->nameText().drawLeftElided(
|
||||
_controller->session().user()->nameText().drawLeftElided(
|
||||
p,
|
||||
st::mainMenuCoverTextLeft,
|
||||
st::mainMenuCoverNameTop,
|
||||
|
@ -429,7 +436,9 @@ void MainMenu::paintEvent(QPaintEvent *e) {
|
|||
|
||||
// Draw Archive button.
|
||||
if (!_archiveButton->isHidden()) {
|
||||
if (const auto folder = Auth().data().folderLoaded(Data::Folder::kId)) {
|
||||
const auto folder = _controller->session().data().folderLoaded(
|
||||
Data::Folder::kId);
|
||||
if (folder) {
|
||||
folder->paintUserpic(
|
||||
p,
|
||||
_archiveButton->x() + (_archiveButton->width() - st::mainMenuCloudSize) / 2,
|
||||
|
|
|
@ -105,8 +105,8 @@ private:
|
|||
|
||||
};
|
||||
|
||||
History *FindWastedPin(Data::Folder *folder) {
|
||||
const auto &order = Auth().data().pinnedChatsOrder(folder);
|
||||
History *FindWastedPin(not_null<Data::Session*> data, Data::Folder *folder) {
|
||||
const auto &order = data->pinnedChatsOrder(folder);
|
||||
for (const auto &pinned : order) {
|
||||
if (const auto history = pinned.history()) {
|
||||
if (history->peer->isChat()
|
||||
|
@ -126,17 +126,19 @@ void AddChatMembers(not_null<ChatData*> chat) {
|
|||
bool PinnedLimitReached(Dialogs::Key key) {
|
||||
Expects(key.entry()->folderKnown());
|
||||
|
||||
const auto folder = key.entry()->folder();
|
||||
const auto pinnedCount = Auth().data().pinnedChatsCount(folder);
|
||||
const auto pinnedMax = Auth().data().pinnedChatsLimit(folder);
|
||||
const auto entry = key.entry();
|
||||
const auto owner = &entry->owner();
|
||||
const auto folder = entry->folder();
|
||||
const auto pinnedCount = owner->pinnedChatsCount(folder);
|
||||
const auto pinnedMax = owner->pinnedChatsLimit(folder);
|
||||
if (pinnedCount < pinnedMax) {
|
||||
return false;
|
||||
}
|
||||
// Some old chat, that was converted, maybe is still pinned.
|
||||
if (const auto wasted = FindWastedPin(folder)) {
|
||||
Auth().data().setChatPinned(wasted, false);
|
||||
Auth().data().setChatPinned(key, true);
|
||||
Auth().api().savePinnedOrder(folder);
|
||||
if (const auto wasted = FindWastedPin(owner, folder)) {
|
||||
owner->setChatPinned(wasted, false);
|
||||
owner->setChatPinned(key, true);
|
||||
entry->session().api().savePinnedOrder(folder);
|
||||
} else {
|
||||
auto errorText = tr::lng_error_pinned_max(
|
||||
tr::now,
|
||||
|
@ -151,12 +153,13 @@ void TogglePinnedDialog(Dialogs::Key key) {
|
|||
if (!key.entry()->folderKnown()) {
|
||||
return;
|
||||
}
|
||||
const auto owner = &key.entry()->owner();
|
||||
const auto isPinned = !key.entry()->isPinnedDialog();
|
||||
if (isPinned && PinnedLimitReached(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Auth().data().setChatPinned(key, isPinned);
|
||||
owner->setChatPinned(key, isPinned);
|
||||
const auto flags = isPinned
|
||||
? MTPmessages_ToggleDialogPin::Flag::f_pinned
|
||||
: MTPmessages_ToggleDialogPin::Flag(0);
|
||||
|
@ -165,7 +168,7 @@ void TogglePinnedDialog(Dialogs::Key key) {
|
|||
MTP_flags(flags),
|
||||
MTP_inputDialogPeer(key.history()->peer->input)
|
||||
)).done([=](const MTPBool &result) {
|
||||
Auth().data().notifyPinnedDialogsOrderUpdated();
|
||||
owner->notifyPinnedDialogsOrderUpdated();
|
||||
}).send();
|
||||
} else if (const auto folder = key.folder()) {
|
||||
folder->session().api().request(MTPmessages_ToggleDialogPin(
|
||||
|
@ -199,8 +202,8 @@ bool Filler::showInfo() {
|
|||
} else if (!Adaptive::ThreeColumn()) {
|
||||
return true;
|
||||
} else if (
|
||||
!Auth().settings().thirdSectionInfoEnabled() &&
|
||||
!Auth().settings().tabbedReplacedWithInfo()) {
|
||||
!_peer->session().settings().thirdSectionInfoEnabled() &&
|
||||
!_peer->session().settings().tabbedReplacedWithInfo()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -290,9 +293,11 @@ void Filler::addToggleUnreadMark() {
|
|||
const auto markAsRead = isUnread(peer);
|
||||
const auto handle = [&](not_null<History*> history) {
|
||||
if (markAsRead) {
|
||||
Auth().api().readServerHistory(history);
|
||||
peer->session().api().readServerHistory(history);
|
||||
} else {
|
||||
Auth().api().changeDialogUnreadMark(history, !markAsRead);
|
||||
peer->session().api().changeDialogUnreadMark(
|
||||
history,
|
||||
!markAsRead);
|
||||
}
|
||||
};
|
||||
const auto history = peer->owner().history(peer);
|
||||
|
@ -361,16 +366,16 @@ void Filler::addBlockUser(not_null<UserData*> user) {
|
|||
}, *lifetime);
|
||||
|
||||
if (user->blockStatus() == UserData::BlockStatus::Unknown) {
|
||||
Auth().api().requestFullPeer(user);
|
||||
user->session().api().requestFullPeer(user);
|
||||
}
|
||||
}
|
||||
|
||||
void Filler::addUserActions(not_null<UserData*> user) {
|
||||
const auto window = &_controller->window()->controller();
|
||||
if (_source != PeerMenuSource::ChatsList) {
|
||||
if (Auth().supportMode()) {
|
||||
if (user->session().supportMode()) {
|
||||
_addAction("Edit support info", [=] {
|
||||
Auth().supportHelper().editInfo(user);
|
||||
user->session().supportHelper().editInfo(user);
|
||||
});
|
||||
}
|
||||
if (!user->isContact() && !user->isSelf() && !user->isBot()) {
|
||||
|
@ -409,7 +414,7 @@ void Filler::addUserActions(not_null<UserData*> user) {
|
|||
tr::lng_profile_clear_history(tr::now),
|
||||
ClearHistoryHandler(user));
|
||||
if (!user->isInaccessible()
|
||||
&& user != Auth().user()
|
||||
&& user != user->session().user()
|
||||
&& _source != PeerMenuSource::ChatsList) {
|
||||
addBlockUser(user);
|
||||
}
|
||||
|
@ -503,7 +508,7 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) {
|
|||
: tr::lng_profile_join_channel(tr::now);
|
||||
_addAction(
|
||||
text,
|
||||
[channel] { Auth().api().joinChannel(channel); });
|
||||
[=] { channel->session().api().joinChannel(channel); });
|
||||
}
|
||||
if (_source != PeerMenuSource::ChatsList) {
|
||||
const auto needReport = !channel->amCreator()
|
||||
|
@ -622,7 +627,7 @@ void FolderFiller::addTogglesForArchive() {
|
|||
} // namespace
|
||||
|
||||
void PeerMenuExportChat(not_null<PeerData*> peer) {
|
||||
Auth().data().startExport(peer);
|
||||
peer->owner().startExport(peer);
|
||||
}
|
||||
|
||||
void PeerMenuDeleteContact(not_null<UserData*> user) {
|
||||
|
@ -654,7 +659,7 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
|
|||
return;
|
||||
} else if (peer->isSelf()) {
|
||||
auto options = ApiWrap::SendOptions(peer->owner().history(peer));
|
||||
Auth().api().shareContact(user, options);
|
||||
user->session().api().shareContact(user, options);
|
||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
||||
if (auto strong = *weak) {
|
||||
strong->closeBox();
|
||||
|
@ -671,7 +676,7 @@ void PeerMenuShareContactBox(not_null<UserData*> user) {
|
|||
const auto history = peer->owner().history(peer);
|
||||
Ui::showPeerHistory(history, ShowAtTheEndMsgId);
|
||||
auto options = ApiWrap::SendOptions(history);
|
||||
Auth().api().shareContact(user, options);
|
||||
user->session().api().shareContact(user, options);
|
||||
}), LayerOption::KeepOther);
|
||||
};
|
||||
*weak = Ui::show(Box<PeerListBox>(
|
||||
|
@ -698,8 +703,8 @@ void PeerMenuCreatePoll(not_null<PeerData*> peer) {
|
|||
if (const auto localDraft = options.history->localDraft()) {
|
||||
options.clearDraft = localDraft->textWithTags.text.isEmpty();
|
||||
}
|
||||
|
||||
Auth().api().createPoll(result, options, crl::guard(box, [=] {
|
||||
const auto api = &peer->session().api();
|
||||
api->createPoll(result, options, crl::guard(box, [=] {
|
||||
box->closeBox();
|
||||
}), crl::guard(box, [=](const RPCError &error) {
|
||||
*lock = false;
|
||||
|
@ -802,11 +807,12 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
|
|||
weak
|
||||
](not_null<PeerData*> peer) mutable {
|
||||
if (peer->isSelf()) {
|
||||
auto items = Auth().data().idsToItems(ids);
|
||||
auto items = peer->owner().idsToItems(ids);
|
||||
if (!items.empty()) {
|
||||
const auto api = &peer->session().api();
|
||||
auto options = ApiWrap::SendOptions(peer->owner().history(peer));
|
||||
options.generateLocal = false;
|
||||
Auth().api().forwardMessages(std::move(items), options, [] {
|
||||
api->forwardMessages(std::move(items), options, [] {
|
||||
Ui::Toast::Show(tr::lng_share_done(tr::now));
|
||||
});
|
||||
}
|
||||
|
@ -839,8 +845,10 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
|
|||
LayerOption::KeepOther);
|
||||
return;
|
||||
}
|
||||
auto callback = [=](const MTPchannels_ChannelParticipants &result) {
|
||||
Auth().api().parseChannelParticipants(channel, result, [&](
|
||||
const auto api = &channel->session().api();
|
||||
api->requestChannelMembersForAdd(channel, [=](
|
||||
const MTPchannels_ChannelParticipants &result) {
|
||||
api->parseChannelParticipants(channel, result, [&](
|
||||
int availableCount,
|
||||
const QVector<MTPChannelParticipant> &list) {
|
||||
auto already = (
|
||||
|
@ -849,8 +857,8 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
|
|||
return p.match([](const auto &data) {
|
||||
return data.vuser_id().v;
|
||||
});
|
||||
}) | ranges::view::transform([](UserId userId) {
|
||||
return Auth().data().userLoaded(userId);
|
||||
}) | ranges::view::transform([&](UserId userId) {
|
||||
return channel->owner().userLoaded(userId);
|
||||
}) | ranges::view::filter([](UserData *user) {
|
||||
return (user != nullptr);
|
||||
}) | ranges::to_vector;
|
||||
|
@ -859,24 +867,23 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) {
|
|||
channel,
|
||||
{ already.begin(), already.end() });
|
||||
});
|
||||
};
|
||||
Auth().api().requestChannelMembersForAdd(channel, callback);
|
||||
});
|
||||
}
|
||||
|
||||
void PeerMenuAddMuteAction(
|
||||
not_null<PeerData*> peer,
|
||||
const PeerMenuCallback &addAction) {
|
||||
Auth().data().requestNotifySettings(peer);
|
||||
peer->owner().requestNotifySettings(peer);
|
||||
const auto muteText = [](bool isMuted) {
|
||||
return isMuted
|
||||
? tr::lng_enable_notifications_from_tray(tr::now)
|
||||
: tr::lng_disable_notifications_from_tray(tr::now);
|
||||
};
|
||||
const auto muteAction = addAction(QString("-"), [=] {
|
||||
if (!Auth().data().notifyIsMuted(peer)) {
|
||||
if (!peer->owner().notifyIsMuted(peer)) {
|
||||
Ui::show(Box<MuteSettingsBox>(peer));
|
||||
} else {
|
||||
Auth().data().updateNotifySettings(peer, 0);
|
||||
peer->owner().updateNotifySettings(peer, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -892,7 +899,7 @@ void PeerMenuAddMuteAction(
|
|||
// Ui::show(Box<ConfirmBox>(
|
||||
// tr::lng_feed_sure_ungroup_all(tr::now),
|
||||
// tr::lng_feed_ungroup_sure(tr::now),
|
||||
// [=] { Ui::hideLayer(); Auth().api().ungroupAllFromFeed(feed); }));
|
||||
// [=] { Ui::hideLayer(); feed->session().api().ungroupAllFromFeed(feed); }));
|
||||
//}
|
||||
//
|
||||
void ToggleHistoryArchived(not_null<History*> history, bool archived) {
|
||||
|
|
Loading…
Add table
Reference in a new issue