mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Move some calls from App namespace.
This commit is contained in:
@@ -766,9 +766,9 @@ void History::eraseFromUnreadMentions(MsgId msgId) {
|
||||
void History::addUnreadMentionsSlice(const MTPmessages_Messages &result) {
|
||||
auto count = 0;
|
||||
auto messages = (const QVector<MTPMessage>*)nullptr;
|
||||
auto getMessages = [](auto &list) {
|
||||
App::feedUsers(list.vusers);
|
||||
App::feedChats(list.vchats);
|
||||
auto getMessages = [&](auto &list) {
|
||||
owner().processUsers(list.vusers);
|
||||
owner().processChats(list.vchats);
|
||||
return &list.vmessages.v;
|
||||
};
|
||||
switch (result.type()) {
|
||||
@@ -952,12 +952,11 @@ void History::applyServiceChanges(
|
||||
switch (action.type()) {
|
||||
case mtpc_messageActionChatAddUser: {
|
||||
auto &d = action.c_messageActionChatAddUser();
|
||||
if (auto megagroup = peer->asMegagroup()) {
|
||||
auto mgInfo = megagroup->mgInfo.get();
|
||||
if (const auto megagroup = peer->asMegagroup()) {
|
||||
const auto mgInfo = megagroup->mgInfo.get();
|
||||
Assert(mgInfo != nullptr);
|
||||
auto &v = d.vusers.v;
|
||||
for (auto i = 0, l = v.size(); i != l; ++i) {
|
||||
if (auto user = App::userLoaded(peerFromUser(v[i]))) {
|
||||
for (const auto &userId : d.vusers.v) {
|
||||
if (const auto user = owner().userLoaded(userId.v)) {
|
||||
if (!base::contains(mgInfo->lastParticipants, user)) {
|
||||
mgInfo->lastParticipants.push_front(user);
|
||||
Notify::peerUpdatedDelayed(peer, Notify::PeerUpdate::Flag::MembersChanged);
|
||||
@@ -1003,12 +1002,12 @@ void History::applyServiceChanges(
|
||||
|
||||
case mtpc_messageActionChatDeleteUser: {
|
||||
auto &d = action.c_messageActionChatDeleteUser();
|
||||
auto uid = peerFromUser(d.vuser_id);
|
||||
if (lastKeyboardFrom == uid) {
|
||||
auto uid = d.vuser_id.v;
|
||||
if (lastKeyboardFrom == peerFromUser(uid)) {
|
||||
clearLastKeyboard();
|
||||
}
|
||||
if (auto megagroup = peer->asMegagroup()) {
|
||||
if (auto user = App::userLoaded(uid)) {
|
||||
if (auto user = owner().userLoaded(uid)) {
|
||||
auto mgInfo = megagroup->mgInfo.get();
|
||||
Assert(mgInfo != nullptr);
|
||||
auto i = ranges::find(
|
||||
@@ -1047,7 +1046,7 @@ void History::applyServiceChanges(
|
||||
if (d.vphoto.type() == mtpc_photo) {
|
||||
auto &sizes = d.vphoto.c_photo().vsizes.v;
|
||||
if (!sizes.isEmpty()) {
|
||||
auto photo = _owner->photo(d.vphoto.c_photo());
|
||||
auto photo = _owner->processPhoto(d.vphoto.c_photo());
|
||||
if (photo) photo->peer = peer;
|
||||
auto &smallSize = sizes.front();
|
||||
auto &bigSize = sizes.back();
|
||||
@@ -1084,7 +1083,7 @@ void History::applyServiceChanges(
|
||||
if (const auto chat = peer->asChat()) {
|
||||
chat->addFlags(MTPDchat::Flag::f_deactivated);
|
||||
const auto &d = action.c_messageActionChatMigrateTo();
|
||||
if (const auto channel = App::channelLoaded(d.vchannel_id.v)) {
|
||||
if (const auto channel = owner().channelLoaded(d.vchannel_id.v)) {
|
||||
Data::ApplyMigration(chat, channel);
|
||||
}
|
||||
}
|
||||
@@ -1094,7 +1093,7 @@ void History::applyServiceChanges(
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
channel->addFlags(MTPDchannel::Flag::f_megagroup);
|
||||
const auto &d = action.c_messageActionChannelMigrateFrom();
|
||||
if (const auto chat = App::chatLoaded(d.vchat_id.v)) {
|
||||
if (const auto chat = owner().chatLoaded(d.vchat_id.v)) {
|
||||
Data::ApplyMigration(chat, channel);
|
||||
}
|
||||
}
|
||||
@@ -1482,7 +1481,7 @@ void History::inboxRead(MsgId upTo) {
|
||||
setInboxReadTill(upTo);
|
||||
updateChatListEntry();
|
||||
if (peer->migrateTo()) {
|
||||
if (auto migrateTo = App::historyLoaded(peer->migrateTo()->id)) {
|
||||
if (auto migrateTo = peer->owner().historyLoaded(peer->migrateTo()->id)) {
|
||||
migrateTo->updateChatListEntry();
|
||||
}
|
||||
}
|
||||
@@ -1899,7 +1898,7 @@ History *History::migrateSibling() const {
|
||||
}
|
||||
return PeerId(0);
|
||||
}();
|
||||
return App::historyLoaded(addFromId);
|
||||
return owner().historyLoaded(addFromId);
|
||||
}
|
||||
|
||||
int History::chatListUnreadCount() const {
|
||||
@@ -1997,7 +1996,7 @@ bool History::loadedAtTop() const {
|
||||
bool History::isReadyFor(MsgId msgId) {
|
||||
if (msgId < 0 && -msgId < ServerMaxMsgId && peer->migrateFrom()) {
|
||||
// Old group history.
|
||||
return App::history(peer->migrateFrom()->id)->isReadyFor(-msgId);
|
||||
return owner().history(peer->migrateFrom()->id)->isReadyFor(-msgId);
|
||||
}
|
||||
|
||||
if (msgId == ShowAtTheEndMsgId) {
|
||||
@@ -2005,7 +2004,7 @@ bool History::isReadyFor(MsgId msgId) {
|
||||
}
|
||||
if (msgId == ShowAtUnreadMsgId) {
|
||||
if (const auto migratePeer = peer->migrateFrom()) {
|
||||
if (const auto migrated = App::historyLoaded(migratePeer)) {
|
||||
if (const auto migrated = owner().historyLoaded(migratePeer)) {
|
||||
if (migrated->unreadCount()) {
|
||||
return migrated->isReadyFor(msgId);
|
||||
}
|
||||
@@ -2026,7 +2025,7 @@ bool History::isReadyFor(MsgId msgId) {
|
||||
|
||||
void History::getReadyFor(MsgId msgId) {
|
||||
if (msgId < 0 && -msgId < ServerMaxMsgId && peer->migrateFrom()) {
|
||||
const auto migrated = App::history(peer->migrateFrom()->id);
|
||||
const auto migrated = owner().history(peer->migrateFrom()->id);
|
||||
migrated->getReadyFor(-msgId);
|
||||
if (migrated->isEmpty()) {
|
||||
unloadBlocks();
|
||||
@@ -2035,7 +2034,7 @@ void History::getReadyFor(MsgId msgId) {
|
||||
}
|
||||
if (msgId == ShowAtUnreadMsgId) {
|
||||
if (const auto migratePeer = peer->migrateFrom()) {
|
||||
if (const auto migrated = App::historyLoaded(migratePeer)) {
|
||||
if (const auto migrated = owner().historyLoaded(migratePeer)) {
|
||||
if (migrated->unreadCount()) {
|
||||
unloadBlocks();
|
||||
migrated->getReadyFor(msgId);
|
||||
@@ -2047,7 +2046,7 @@ void History::getReadyFor(MsgId msgId) {
|
||||
if (!isReadyFor(msgId)) {
|
||||
unloadBlocks();
|
||||
if (const auto migratePeer = peer->migrateFrom()) {
|
||||
if (const auto migrated = App::historyLoaded(migratePeer)) {
|
||||
if (const auto migrated = owner().historyLoaded(migratePeer)) {
|
||||
migrated->unloadBlocks();
|
||||
}
|
||||
}
|
||||
@@ -2383,7 +2382,7 @@ void History::dialogEntryApplied() {
|
||||
} else if (const auto channel = peer->asChannel()) {
|
||||
const auto inviter = channel->inviter;
|
||||
if (inviter != 0 && channel->amIn()) {
|
||||
if (const auto from = App::userLoaded(inviter)) {
|
||||
if (const auto from = owner().userLoaded(inviter)) {
|
||||
unloadBlocks();
|
||||
addNewerSlice(QVector<MTPMessage>());
|
||||
insertJoinedMessage(true);
|
||||
@@ -2401,7 +2400,7 @@ void History::dialogEntryApplied() {
|
||||
if (inviter > 0
|
||||
&& chatListTimeId() <= channel->inviteDate
|
||||
&& channel->amIn()) {
|
||||
if (const auto from = App::userLoaded(inviter)) {
|
||||
if (const auto from = owner().userLoaded(inviter)) {
|
||||
insertJoinedMessage(true);
|
||||
}
|
||||
}
|
||||
@@ -2582,15 +2581,15 @@ bool History::isMegagroup() const {
|
||||
|
||||
not_null<History*> History::migrateToOrMe() const {
|
||||
if (const auto to = peer->migrateTo()) {
|
||||
return App::history(to);
|
||||
return owner().history(to);
|
||||
}
|
||||
// We could get it by App::history(peer), but we optimize.
|
||||
// We could get it by owner().history(peer), but we optimize.
|
||||
return const_cast<History*>(this);
|
||||
}
|
||||
|
||||
History *History::migrateFrom() const {
|
||||
if (const auto from = peer->migrateFrom()) {
|
||||
return App::history(from);
|
||||
return owner().history(from);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -2636,7 +2635,7 @@ HistoryService *History::insertJoinedMessage(bool unread) {
|
||||
}
|
||||
|
||||
const auto inviter = (peer->asChannel()->inviter > 0)
|
||||
? App::userLoaded(peer->asChannel()->inviter)
|
||||
? owner().userLoaded(peer->asChannel()->inviter)
|
||||
: nullptr;
|
||||
if (!inviter) {
|
||||
return nullptr;
|
||||
|
Reference in New Issue
Block a user