2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 00:46:08 +00:00

Replace App::self() with Auth().user().

Always have self Auth().user() when AuthSession exists.
This commit is contained in:
John Preston
2018-09-11 15:50:40 +03:00
parent 12ebae01b0
commit 0c8709ca5f
41 changed files with 227 additions and 230 deletions

View File

@@ -49,8 +49,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace {
App::LaunchState _launchState = App::Launched;
UserData *self = nullptr;
std::unordered_map<PeerId, std::unique_ptr<PeerData>> peersData;
using LocationsData = QHash<LocationCoords, LocationData*>;
@@ -309,10 +307,6 @@ namespace App {
: data->phone().isEmpty()
? UserData::ContactStatus::PhoneUnknown
: UserData::ContactStatus::CanAdd);
if (d.is_self() && ::self != data) {
::self = data;
Global::RefSelfChanged().notify();
}
}
if (canShareThisContact != data->canShareThisContactFast()) {
@@ -334,8 +328,10 @@ namespace App {
}
if (status && !minimal) {
auto oldOnlineTill = data->onlineTill;
auto newOnlineTill = Auth().api().onlineTillFromStatus(*status, oldOnlineTill);
const auto oldOnlineTill = data->onlineTill;
const auto newOnlineTill = ApiWrap::OnlineTillFromStatus(
*status,
oldOnlineTill);
if (oldOnlineTill != newOnlineTill) {
data->onlineTill = newOnlineTill;
update.flags |= UpdateFlag::UserOnlineChanged;
@@ -344,7 +340,7 @@ namespace App {
if (data->contactStatus() == UserData::ContactStatus::PhoneUnknown
&& !data->phone().isEmpty()
&& data->id != Auth().userPeerId()) {
&& !data->isSelf()) {
data->setContactStatus(UserData::ContactStatus::CanAdd);
}
if (App::main()) {
@@ -918,7 +914,7 @@ namespace App {
}
void checkSavedGif(HistoryItem *item) {
if (!item->Has<HistoryMessageForwarded>() && (item->out() || item->history()->peer == App::self())) {
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()) {
@@ -1153,10 +1149,6 @@ namespace App {
}
}
UserData *self() {
return ::self;
}
PeerData *peerByName(const QString &username) {
const auto uname = username.trimmed();
for (const auto &[peerId, peer] : peersData) {
@@ -1294,8 +1286,6 @@ namespace App {
cSetAutoDownloadPhoto(0);
cSetAutoDownloadAudio(0);
cSetAutoDownloadGif(0);
::self = nullptr;
Global::RefSelfChanged().notify(true);
}
void historyRegDependency(HistoryItem *dependent, HistoryItem *dependency) {