mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Remove Session::Exists() global access point.
This commit is contained in:
@@ -216,7 +216,10 @@ PeerData *readPeer(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto loaded = session->data().peerLoaded(peerId);
|
||||
const auto selfId = session->userPeerId();
|
||||
const auto loaded = (peerId == selfId)
|
||||
? session->user().get()
|
||||
: session->data().peerLoaded(peerId);
|
||||
const auto result = loaded ? loaded : session->data().peer(peerId).get();
|
||||
if (!loaded) {
|
||||
result->loadedStatus = PeerData::FullLoaded;
|
||||
@@ -237,7 +240,7 @@ PeerData *readPeer(
|
||||
userpicAccessHash = access;
|
||||
|
||||
const auto showPhone = !user->isServiceUser()
|
||||
&& (user->id != session->userPeerId())
|
||||
&& (user->id != selfId)
|
||||
&& (contact <= 0);
|
||||
const auto pname = (showPhone && !phone.isEmpty())
|
||||
? App::formatPhone(phone)
|
||||
@@ -256,7 +259,7 @@ PeerData *readPeer(
|
||||
user->botInfo->inlinePlaceholder = inlinePlaceholder;
|
||||
}
|
||||
|
||||
if (user->id == session->userPeerId()) {
|
||||
if (user->id == selfId) {
|
||||
user->input = MTP_inputPeerSelf();
|
||||
user->inputUser = MTP_inputUserSelf();
|
||||
} else {
|
||||
|
||||
@@ -2444,14 +2444,17 @@ void Account::writeSelf() {
|
||||
writeMapDelayed();
|
||||
}
|
||||
|
||||
void Account::readSelf(const QByteArray &serialized, int32 streamVersion) {
|
||||
void Account::readSelf(
|
||||
not_null<Main::Session*> session,
|
||||
const QByteArray &serialized,
|
||||
int32 streamVersion) {
|
||||
QDataStream stream(serialized);
|
||||
const auto user = _owner->session().user();
|
||||
const auto user = session->user();
|
||||
const auto wasLoadedStatus = std::exchange(
|
||||
user->loadedStatus,
|
||||
PeerData::NotLoaded);
|
||||
const auto self = Serialize::readPeer(
|
||||
&_owner->session(),
|
||||
session,
|
||||
streamVersion,
|
||||
stream);
|
||||
if (!self || !self->isSelf() || self != user) {
|
||||
|
||||
@@ -120,7 +120,13 @@ public:
|
||||
[[nodiscard]] Export::Settings readExportSettings();
|
||||
|
||||
void writeSelf();
|
||||
void readSelf(const QByteArray &serialized, int32 streamVersion);
|
||||
|
||||
// Read self is special, it can't get session from account, because
|
||||
// it is not really there yet - it is still being constructed.
|
||||
void readSelf(
|
||||
not_null<Main::Session*> session,
|
||||
const QByteArray& serialized,
|
||||
int32 streamVersion);
|
||||
|
||||
void markBotTrusted(not_null<UserData*> bot);
|
||||
[[nodiscard]] bool isBotTrusted(not_null<UserData*> bot);
|
||||
|
||||
@@ -104,8 +104,7 @@ BlobLoader::BlobLoader(
|
||||
, _folder(folder)
|
||||
, _id(id)
|
||||
, _state(Loading{ 0, size })
|
||||
, _mtproto(session->account().mtp())
|
||||
, _mtprotoUserId(session->userId()) {
|
||||
, _mtproto(session.get()) {
|
||||
const auto ready = [=](std::unique_ptr<MTP::DedicatedLoader> loader) {
|
||||
if (loader) {
|
||||
setImplementation(std::move(loader));
|
||||
@@ -113,12 +112,7 @@ BlobLoader::BlobLoader(
|
||||
fail();
|
||||
}
|
||||
};
|
||||
MTP::StartDedicatedLoader(
|
||||
&_mtproto,
|
||||
_mtprotoUserId,
|
||||
location,
|
||||
_folder,
|
||||
ready);
|
||||
MTP::StartDedicatedLoader(&_mtproto, location, _folder, ready);
|
||||
}
|
||||
|
||||
int BlobLoader::id() const {
|
||||
|
||||
@@ -107,7 +107,6 @@ private:
|
||||
rpl::variable<BlobState> _state;
|
||||
|
||||
MTP::WeakInstance _mtproto;
|
||||
int32 _mtprotoUserId = 0;
|
||||
|
||||
std::unique_ptr<MTP::DedicatedLoader> _implementation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user