added some checks

This commit is contained in:
John Preston 2015-10-03 14:33:51 +03:00
parent e3e774176e
commit 605b18aa27
12 changed files with 39 additions and 29 deletions

View File

@ -626,7 +626,7 @@ namespace App {
} else {
if (i.key()->botInfo) {
botStatus = (botStatus > 0/* || i.key()->botInfo->readsAllHistory*/) ? 2 : 1;
if (requestBotInfos && !i.key()->botInfo->inited) App::api()->requestFullPeer(i.key());
if (requestBotInfos && !i.key()->botInfo->inited && App::api()) App::api()->requestFullPeer(i.key());
}
if (!found && i.key()->id == h->lastKeyboardFrom) {
found = true;
@ -676,7 +676,7 @@ namespace App {
chat->count++;
if (user->botInfo) {
chat->botStatus = (chat->botStatus > 0/* || !user->botInfo->readsAllHistory*/) ? 2 : 1;
if (!user->botInfo->inited) App::api()->requestFullPeer(user);
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
}
}
} else {

View File

@ -12,6 +12,9 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014 John Preston, https://desktop.telegram.org
*/

View File

@ -12,6 +12,9 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
In addition, as a special exception, the copyright holders give permission
to link the code of portions of this program with the OpenSSL library.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
Copyright (c) 2014 John Preston, https://desktop.telegram.org
*/

View File

@ -577,7 +577,7 @@ bool EditChannelBox::onSaveFail(const RPCError &error, mtpRequestId req) {
_saveDescriptionRequestId = 0;
if (err == qstr("CHAT_ABOUT_NOT_MODIFIED")) {
_channel->about = _sentDescription;
emit App::api()->fullPeerUpdated(_channel);
if (App::api()) emit App::api()->fullPeerUpdated(_channel);
onClose();
} else {
_description.setFocus();
@ -595,6 +595,6 @@ void EditChannelBox::onSaveTitleDone(const MTPUpdates &updates) {
void EditChannelBox::onSaveDescriptionDone(const MTPBool &result) {
_saveDescriptionRequestId = 0;
_channel->about = _sentDescription;
emit App::api()->fullPeerUpdated(_channel);
if (App::api()) emit App::api()->fullPeerUpdated(_channel);
onClose();
}

View File

@ -796,7 +796,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
history->peer->asChannel()->ptsReceived(d.vpts.v);
if (!history->peer->asChannel()->amCreator()) {
if (HistoryItem *top = App::histItemById(history->channelId(), d.vtop_important_message.v)) {
if (top->date <= date(history->peer->asChannel()->date)) {
if (top->date <= date(history->peer->asChannel()->date) && App::api()) {
App::api()->requestSelfParticipant(history->peer->asChannel());
}
}

View File

@ -2976,7 +2976,7 @@ void MentionsDropdown::updateFiltered(bool toDown) {
QMultiMap<int32, UserData*> ordered;
rows.reserve(_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size());
if (_chat->participants.isEmpty()) {
if (_chat->count > 0) {
if (_chat->count > 0 && App::api()) {
App::api()->requestFullPeer(_chat);
}
} else {
@ -3015,7 +3015,7 @@ void MentionsDropdown::updateFiltered(bool toDown) {
int32 cnt = 0;
if (_chat) {
if (_chat->participants.isEmpty()) {
if (_chat->count > 0) {
if (_chat->count > 0 && App::api()) {
App::api()->requestFullPeer(_chat);
}
} else {
@ -3023,14 +3023,14 @@ void MentionsDropdown::updateFiltered(bool toDown) {
for (ChatData::Participants::const_iterator i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
UserData *user = i.key();
if (!user->botInfo) continue;
if (!user->botInfo->inited) App::api()->requestFullPeer(user);
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (user->botInfo->commands.isEmpty()) continue;
bots.insert(user, true);
cnt += user->botInfo->commands.size();
}
}
} else if (_user && _user->botInfo) {
if (!_user->botInfo->inited) App::api()->requestFullPeer(_user);
if (!_user->botInfo->inited && App::api()) App::api()->requestFullPeer(_user);
cnt = _user->botInfo->commands.size();
bots.insert(_user, true);
}
@ -3042,7 +3042,7 @@ void MentionsDropdown::updateFiltered(bool toDown) {
UserData *user = *i;
if (!user->botInfo) continue;
if (!bots.contains(user)) continue;
if (!user->botInfo->inited) App::api()->requestFullPeer(user);
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (user->botInfo->commands.isEmpty()) continue;
bots.remove(user);
for (int32 j = 0, l = user->botInfo->commands.size(); j < l; ++j) {

View File

@ -6963,7 +6963,7 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, const MTPDmess
, replyToVersion(0)
, _maxReplyWidth(0)
{
if (!updateReplyTo()) {
if (!updateReplyTo() && App::api()) {
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
}
}
@ -6974,7 +6974,7 @@ HistoryReply::HistoryReply(History *history, HistoryBlock *block, MsgId msgId, i
, replyToVersion(0)
, _maxReplyWidth(0)
{
if (!updateReplyTo()) {
if (!updateReplyTo() && App::api()) {
App::api()->requestReplyTo(this, history->peer->asChannel(), replyToMsgId);
}
}
@ -7285,7 +7285,7 @@ void HistoryReply::getSymbol(uint16 &symbol, bool &after, bool &upon, int32 x, i
HistoryReply::~HistoryReply() {
if (replyToMsg) {
App::historyUnregReply(this, replyToMsg);
} else if (replyToMsgId) {
} else if (replyToMsgId && App::api()) {
App::api()->itemRemoved(this);
}
}

View File

@ -75,7 +75,7 @@ HistoryInner::HistoryInner(HistoryWidget *historyWidget, ScrollArea *scroll, His
_trippleClickTimer.setSingleShot(true);
if (botInfo && !botInfo->inited) {
if (botInfo && !botInfo->inited && App::api()) {
App::api()->requestFullPeer(hist->peer);
}
@ -2746,7 +2746,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
}
}
if (!setsToRequest.isEmpty()) {
if (!setsToRequest.isEmpty() && App::api()) {
for (QMap<uint64, uint64>::const_iterator i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
App::api()->scheduleStickerSetRequest(i.key(), i.value());
}
@ -3018,7 +3018,7 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
}
if (_replyToId) {
updateReplyTo();
if (!_replyTo) App::api()->requestReplyTo(0, _peer->asChannel(), _replyToId);
if (!_replyTo && App::api()) App::api()->requestReplyTo(0, _peer->asChannel(), _replyToId);
}
resizeEvent(0);
if (!_previewCancelled) {
@ -5914,10 +5914,12 @@ void HistoryWidget::peerUpdated(PeerData *data) {
if (data && data == _peer) {
updateListSize();
if (_peer->isChannel()) updateReportSpamStatus();
if (data->isChat() && data->asChat()->count > 0 && data->asChat()->participants.isEmpty()) {
App::api()->requestFullPeer(data);
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
App::api()->requestFullPeer(data);
if (App::api()) {
if (data->isChat() && data->asChat()->count > 0 && data->asChat()->participants.isEmpty()) {
App::api()->requestFullPeer(data);
} else if (data->isUser() && data->asUser()->blocked == UserBlockUnknown) {
App::api()->requestFullPeer(data);
}
}
if (!_showAnim.animating()) {
bool resize = (_unblock.isHidden() == isBlocked() || (!isBlocked() && _joinChannel.isHidden() == isJoinChannel()));

View File

@ -3112,7 +3112,7 @@ namespace Local {
peers.push_back(peer);
}
App::emitPeerUpdated();
App::api()->requestPeers(peers);
if (App::api()) App::api()->requestPeers(peers);
}
void addSavedPeer(PeerData *peer, const QDateTime &position) {

View File

@ -4109,7 +4109,7 @@ void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
bool noFrom = !App::userLoaded(d.vfrom_id.v);
if (!App::chatLoaded(d.vchat_id.v) || noFrom || (d.has_fwd_from_id() && !App::peerLoaded(peerFromMTP(d.vfwd_from_id)))) {
MTP_LOG(0, ("getDifference { good - getting user for updateShortChatMessage }%1").arg(cTestMode() ? " TESTMODE" : ""));
if (noFrom) App::api()->requestFullPeer(App::chatLoaded(d.vchat_id.v));
if (noFrom && App::api()) App::api()->requestFullPeer(App::chatLoaded(d.vchat_id.v));
return getDifference();
}
@ -4524,7 +4524,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
deleteConversation(channel, false);
} else if (!channel->amCreator() && App::history(channel->id)) { // create history
_updatedChannels.insert(channel, true);
App::api()->requestSelfParticipant(channel);
if (App::api()) App::api()->requestSelfParticipant(channel);
}
}
} break;

View File

@ -93,7 +93,7 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const Pee
_photoLink = TextLinkPtr(new PhotoLink(userPhoto, _peer));
}
if ((_peerUser->botInfo && !_peerUser->botInfo->inited) || (_peerUser->photoId == UnknownPeerPhotoId) || (_peerUser->photoId && !userPhoto->date) || (_peerUser->blocked == UserBlockUnknown)) {
App::api()->requestFullPeer(_peer);
if (App::api()) App::api()->requestFullPeer(_peer);
}
} else if (_peerChat) {
PhotoData *chatPhoto = (_peerChat->photoId && _peerChat->photoId != UnknownPeerPhotoId) ? App::photo(_peerChat->photoId) : 0;
@ -101,7 +101,7 @@ ProfileInner::ProfileInner(ProfileWidget *profile, ScrollArea *scroll, const Pee
_photoLink = TextLinkPtr(new PhotoLink(chatPhoto, _peer));
}
if (_peerChat->photoId == UnknownPeerPhotoId) {
App::api()->requestFullPeer(_peer);
if (App::api()) App::api()->requestFullPeer(_peer);
}
} else if (_peerChannel) {
PhotoData *chatPhoto = (_peerChannel->photoId && _peerChannel->photoId != UnknownPeerPhotoId) ? App::photo(_peerChannel->photoId) : 0;
@ -607,7 +607,7 @@ void ProfileInner::reorderParticipants() {
}
}
if (_peerChat->count > 0 && _participants.isEmpty()) {
App::api()->requestFullPeer(_peer);
if (App::api()) App::api()->requestFullPeer(_peer);
if (_onlineText.isEmpty()) _onlineText = lng_chat_status_members(lt_count, _peerChat->count);
} else if (onlineCount && !onlyMe) {
_onlineText = lng_chat_status_members_online(lt_count, _participants.size(), lt_count_online, onlineCount);

View File

@ -385,7 +385,7 @@ void ChannelData::setPhoto(const MTPChatPhoto &p, const PhotoId &phId) { // see
photoId = newPhotoId;
photo = newPhoto;
photoLoc = newPhotoLoc;
emit App::main()->peerPhotoChanged(this);
if (App::main()) emit App::main()->peerPhotoChanged(this);
}
}
@ -397,8 +397,10 @@ void ChannelData::setName(const QString &newName, const QString &usern) {
void ChannelData::updateFull(bool force) {
if (!_lastFullUpdate || force || getms(true) > _lastFullUpdate + UpdateFullChannelTimeout) {
App::api()->requestFullPeer(this);
if (!amCreator() && !inviter) App::api()->requestSelfParticipant(this);
if (App::api()) {
App::api()->requestFullPeer(this);
if (!amCreator() && !inviter) App::api()->requestSelfParticipant(this);
}
}
}