supergroups done

This commit is contained in:
John Preston 2015-11-20 21:24:44 +03:00
parent ecc49f9cd4
commit b05e1a8899
15 changed files with 146 additions and 46 deletions

View File

@ -292,11 +292,11 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
channel->flagsUpdated(); channel->flagsUpdated();
} }
ChatData *cfrom = App::chat(peerFromChat(f.vmigrated_from_chat_id)); ChatData *cfrom = App::chat(peerFromChat(f.vmigrated_from_chat_id));
bool updated = (cfrom->migrateToPtr != channel); bool updatedTo = (cfrom->migrateToPtr != channel), updatedFrom = (channel->mgInfo->migrateFromPtr != cfrom);
if (updated) { if (updatedTo) {
cfrom->migrateToPtr = channel; cfrom->migrateToPtr = channel;
} }
if (channel->mgInfo->migrateFromPtr != cfrom) { if (updatedFrom) {
channel->mgInfo->migrateFromPtr = cfrom; channel->mgInfo->migrateFromPtr = cfrom;
if (History *h = App::historyLoaded(cfrom->id)) { if (History *h = App::historyLoaded(cfrom->id)) {
if (History *hto = App::historyLoaded(channel->id)) { if (History *hto = App::historyLoaded(channel->id)) {
@ -308,8 +308,10 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
} }
} }
} }
Notify::migrateUpdated(channel);
} }
if (updated) { if (updatedTo) {
Notify::migrateUpdated(cfrom);
App::main()->peerUpdated(cfrom); App::main()->peerUpdated(cfrom);
} }
} }
@ -344,9 +346,6 @@ void ApiWrap::gotChatFull(PeerData *peer, const MTPmessages_ChatFull &result, mt
h->inboxReadBefore = f.vread_inbox_max_id.v + 1; h->inboxReadBefore = f.vread_inbox_max_id.v + 1;
h->asChannelHistory()->unreadCountAll = f.vunread_count.v; h->asChannelHistory()->unreadCountAll = f.vunread_count.v;
} }
if (channel->migrateFrom()) {
h->asChannelHistory()->removeJoinedMessage();
}
} }
channel->fullUpdated(); channel->fullUpdated();
@ -449,7 +448,7 @@ void ApiWrap::requestLastParticipants(ChannelData *peer, bool fromStart) {
return; return;
} }
} }
mtpRequestId req = MTP::send(MTPchannels_GetParticipants(peer->inputChannel, MTP_channelParticipantsRecent(), MTP_int(fromStart ? 0 : peer->mgInfo->lastParticipants.size()), MTP_int(1)), rpcDone(&ApiWrap::lastParticipantsDone, peer), rpcFail(&ApiWrap::lastParticipantsFail, peer)); mtpRequestId req = MTP::send(MTPchannels_GetParticipants(peer->inputChannel, MTP_channelParticipantsRecent(), MTP_int(fromStart ? 0 : peer->mgInfo->lastParticipants.size()), MTP_int(cMaxGroupCount())), rpcDone(&ApiWrap::lastParticipantsDone, peer), rpcFail(&ApiWrap::lastParticipantsFail, peer));
_participantsRequests.insert(peer, fromStart ? req : -req); _participantsRequests.insert(peer, fromStart ? req : -req);
} }

View File

@ -510,10 +510,11 @@ namespace App {
channel->inputChannel = d.vmigrated_to; channel->inputChannel = d.vmigrated_to;
channel->access = d.vmigrated_to.c_inputChannel().vaccess_hash.v; channel->access = d.vmigrated_to.c_inputChannel().vaccess_hash.v;
} }
if (cdata->migrateToPtr != channel) { bool updatedTo = (cdata->migrateToPtr != channel), updatedFrom = (channel->mgInfo->migrateFromPtr != cdata);
if (updatedTo) {
cdata->migrateToPtr = channel; cdata->migrateToPtr = channel;
} }
if (channel->mgInfo->migrateFromPtr != cdata) { if (updatedFrom) {
channel->mgInfo->migrateFromPtr = cdata; channel->mgInfo->migrateFromPtr = cdata;
if (History *h = App::historyLoaded(cdata->id)) { if (History *h = App::historyLoaded(cdata->id)) {
if (History *hto = App::historyLoaded(channel->id)) { if (History *hto = App::historyLoaded(channel->id)) {
@ -525,6 +526,10 @@ namespace App {
} }
} }
} }
Notify::migrateUpdated(channel);
}
if (updatedTo) {
Notify::migrateUpdated(cdata);
} }
} }
@ -1044,8 +1049,13 @@ namespace App {
} }
(*j)->destroy(); (*j)->destroy();
if (!h->lastMsg) historiesToCheck.insert(h, true); if (!h->lastMsg) historiesToCheck.insert(h, true);
} else if (channelHistory) { } else {
channelHistory->messageWithIdDeleted(i->v); if (channelHistory) {
channelHistory->messageWithIdDeleted(i->v);
if (channelHistory->unreadCount > 0 && i->v >= channelHistory->inboxReadBefore) {
channelHistory->setUnreadCount(channelHistory->unreadCount - 1);
}
}
} }
} }
if (resized) { if (resized) {
@ -2862,4 +2872,10 @@ namespace Notify {
} }
} }
void migrateUpdated(PeerData *peer) {
if (MainWidget *m = App::main()) {
m->notifyMigrateUpdated(peer);
}
}
} }

View File

@ -317,6 +317,9 @@ namespace App {
}; };
namespace Notify { namespace Notify {
void userIsBotChanged(UserData *user); void userIsBotChanged(UserData *user);
void botCommandsChanged(UserData *user); void botCommandsChanged(UserData *user);
void migrateUpdated(PeerData *peer);
}; };

View File

@ -309,8 +309,8 @@ enum {
DialogsFirstLoad = 20, // first dialogs part size requested DialogsFirstLoad = 20, // first dialogs part size requested
DialogsPerPage = 500, // next dialogs part size DialogsPerPage = 500, // next dialogs part size
MessagesFirstLoad = 3, // first history part size requested MessagesFirstLoad = 30, // first history part size requested
MessagesPerPage = 3, // next history part size MessagesPerPage = 50, // next history part size
FileLoaderQueueStopTimeout = 5000, FileLoaderQueueStopTimeout = 5000,

View File

@ -1756,6 +1756,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
App::feedChats(data.vchats); App::feedChats(data.vchats);
m = &data.vmessages.c_vector().v; m = &data.vmessages.c_vector().v;
v = &data.vdialogs.c_vector().v; v = &data.vdialogs.c_vector().v;
_dialogsFull = true;
} break; } break;
case mtpc_messages_dialogsSlice: { case mtpc_messages_dialogsSlice: {
const MTPDmessages_dialogsSlice &data(dialogs.c_messages_dialogsSlice()); const MTPDmessages_dialogsSlice &data(dialogs.c_messages_dialogsSlice());
@ -1954,8 +1955,7 @@ void DialogsWidget::loadDialogs() {
return; return;
} }
int32 loadCount = (!cTestMode() || _dialogsOffsetDate) ? DialogsPerPage : DialogsFirstLoad; int32 loadCount = _dialogsOffsetDate ? DialogsPerPage : DialogsFirstLoad;
if (!cTestMode() && _dialogsOffsetDate) return;
_dialogsRequest = MTP::send(MTPmessages_GetDialogs(MTP_int(_dialogsOffsetDate), MTP_int(_dialogsOffsetId), _dialogsOffsetPeer ? _dialogsOffsetPeer->input : MTP_inputPeerEmpty(), MTP_int(loadCount)), rpcDone(&DialogsWidget::dialogsReceived), rpcFail(&DialogsWidget::dialogsFailed)); _dialogsRequest = MTP::send(MTPmessages_GetDialogs(MTP_int(_dialogsOffsetDate), MTP_int(_dialogsOffsetId), _dialogsOffsetPeer ? _dialogsOffsetPeer->input : MTP_inputPeerEmpty(), MTP_int(loadCount)), rpcDone(&DialogsWidget::dialogsReceived), rpcFail(&DialogsWidget::dialogsFailed));
} }

View File

@ -703,7 +703,7 @@ void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
} }
HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) { HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
if (_joinedMessage || !peer->asChannel()->amIn() || peer->asChannel()->migrateFrom()) { if (_joinedMessage || !peer->asChannel()->amIn() || (peer->isMegagroup() && peer->asChannel()->mgInfo->joinedMessageFound)) {
return _joinedMessage; return _joinedMessage;
} }
@ -731,6 +731,11 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
HistoryItemType type = item->type(); HistoryItemType type = item->type();
if (type == HistoryItemMsg || type == HistoryItemGroup) { if (type == HistoryItemMsg || type == HistoryItemGroup) {
if (item->date <= inviteDate) { if (item->date <= inviteDate) {
if (peer->isMegagroup() && peer->migrateFrom() && item->isGroupMigrate()) {
peer->asChannel()->mgInfo->joinedMessageFound = true;
return 0;
}
++itemIndex; ++itemIndex;
if (item->date.date() != inviteDate.date()) { if (item->date.date() != inviteDate.date()) {
HistoryDateMsg *joinedDateItem = new HistoryDateMsg(this, block, inviteDate.date()); HistoryDateMsg *joinedDateItem = new HistoryDateMsg(this, block, inviteDate.date());
@ -830,13 +835,15 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
} }
void ChannelHistory::checkJoinedMessage(bool createUnread) { void ChannelHistory::checkJoinedMessage(bool createUnread) {
if (_joinedMessage || peer->asChannel()->inviter <= 0 || peer->asChannel()->migrateFrom()) { if (_joinedMessage || peer->asChannel()->inviter <= 0) {
return; return;
} }
if (isEmpty()) { if (isEmpty()) {
if (loadedAtTop() && loadedAtBottom()) { if (loadedAtTop() && loadedAtBottom()) {
if (insertJoinedMessage(createUnread)) { if (insertJoinedMessage(createUnread)) {
setLastMessage(_joinedMessage); if (!_joinedMessage->detached()) {
setLastMessage(_joinedMessage);
}
} }
return; return;
} }
@ -875,18 +882,13 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
if (!firstDate.isNull() && !lastDate.isNull() && (firstDate <= inviteDate || loadedAtTop()) && (lastDate > inviteDate || loadedAtBottom())) { if (!firstDate.isNull() && !lastDate.isNull() && (firstDate <= inviteDate || loadedAtTop()) && (lastDate > inviteDate || loadedAtBottom())) {
bool willBeLastMsg = (inviteDate >= lastDate); bool willBeLastMsg = (inviteDate >= lastDate);
if (insertJoinedMessage(createUnread && willBeLastMsg) && willBeLastMsg) { if (insertJoinedMessage(createUnread && willBeLastMsg) && willBeLastMsg) {
setLastMessage(_joinedMessage); if (!_joinedMessage->detached()) {
setLastMessage(_joinedMessage);
}
} }
} }
} }
void ChannelHistory::removeJoinedMessage() {
if (_joinedMessage) {
_joinedMessage->destroy();
_joinedMessage = 0;
}
}
void ChannelHistory::checkMaxReadMessageDate() { void ChannelHistory::checkMaxReadMessageDate() {
if (_maxReadMessageDate.isValid()) return; if (_maxReadMessageDate.isValid()) return;
@ -896,11 +898,14 @@ void ChannelHistory::checkMaxReadMessageDate() {
HistoryItem *item = block->items.at(--itemIndex); HistoryItem *item = block->items.at(--itemIndex);
if ((item->isImportant() || isMegagroup()) && !item->unread()) { if ((item->isImportant() || isMegagroup()) && !item->unread()) {
_maxReadMessageDate = item->date; _maxReadMessageDate = item->date;
if (item->isGroupMigrate() && isMegagroup() && peer->migrateFrom()) {
_maxReadMessageDate = date(MTP_int(peer->asChannel()->date + 1)); // no report spam panel
}
return; return;
} }
} }
} }
if (loadedAtTop()) { if (loadedAtTop() && (!isMegagroup() || !isEmpty())) {
_maxReadMessageDate = date(MTP_int(peer->asChannel()->date)); _maxReadMessageDate = date(MTP_int(peer->asChannel()->date));
} }
} }
@ -943,8 +948,6 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
if (!isImportantFlags && !onlyImportant() && !isEmpty() && type == NewMessageLast) { if (!isImportantFlags && !onlyImportant() && !isEmpty() && type == NewMessageLast) {
clear(true); clear(true);
} else if (isMegagroup() && !isEmpty() && type == NewMessageLast && idFromMessage(msg) > maxMsgId()) { // temp
clear(true);
} }
HistoryBlock *to = 0; HistoryBlock *to = 0;
@ -7653,10 +7656,13 @@ void HistoryServiceMsg::setMessageByAction(const MTPmessageAction &action) {
second = TextLinkPtr(new PeerLink(u)); second = TextLinkPtr(new PeerLink(u));
text = lng_action_add_users(lt_from, from, lt_user, textcmdLink(2, u->name), lt_count, v.size() - 1); text = lng_action_add_users(lt_from, from, lt_user, textcmdLink(2, u->name), lt_count, v.size() - 1);
} }
if (unread() && foundSelf) { if (foundSelf) {
if (history()->peer->isChat() && !history()->peer->asChat()->inviterForSpamReport && _from->isUser()) { if (unread() && history()->peer->isChat() && !history()->peer->asChat()->inviterForSpamReport && _from->isUser()) {
history()->peer->asChat()->inviterForSpamReport = peerToUser(_from->id); history()->peer->asChat()->inviterForSpamReport = peerToUser(_from->id);
} }
if (history()->peer->isMegagroup()) {
history()->peer->asChannel()->mgInfo->joinedMessageFound = true;
}
} }
} break; } break;
@ -7669,6 +7675,9 @@ void HistoryServiceMsg::setMessageByAction(const MTPmessageAction &action) {
//second = TextLinkPtr(new PeerLink(u)); //second = TextLinkPtr(new PeerLink(u));
//text = lng_action_user_joined_by_link_from(lt_from, from, lt_inviter, textcmdLink(2, u->name)); //text = lng_action_user_joined_by_link_from(lt_from, from, lt_inviter, textcmdLink(2, u->name));
} }
if (_from->isSelf() && history()->peer->isMegagroup()) {
history()->peer->asChannel()->mgInfo->joinedMessageFound = true;
}
} break; } break;
case mtpc_messageActionChatCreate: { case mtpc_messageActionChatCreate: {

View File

@ -432,7 +432,6 @@ public:
HistoryJoined *insertJoinedMessage(bool unread); HistoryJoined *insertJoinedMessage(bool unread);
void checkJoinedMessage(bool createUnread = false); void checkJoinedMessage(bool createUnread = false);
void removeJoinedMessage();
const QDateTime &maxReadMessageDate(); const QDateTime &maxReadMessageDate();
private: private:

View File

@ -1734,6 +1734,10 @@ void HistoryInner::notifyIsBotChanged() {
} }
} }
void HistoryInner::notifyMigrateUpdated() {
_migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0;
}
void HistoryInner::applyDragSelection() { void HistoryInner::applyDragSelection() {
applyDragSelection(&_selected); applyDragSelection(&_selected);
} }
@ -2616,6 +2620,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
setAcceptDrops(true); setAcceptDrops(true);
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(updateField()));
connect(&_scroll, SIGNAL(scrolled()), this, SLOT(onListScroll())); connect(&_scroll, SIGNAL(scrolled()), this, SLOT(onListScroll()));
connect(&_reportSpamPanel, SIGNAL(reportClicked()), this, SLOT(onReportSpamClicked())); connect(&_reportSpamPanel, SIGNAL(reportClicked()), this, SLOT(onReportSpamClicked()));
connect(&_reportSpamPanel, SIGNAL(hideClicked()), this, SLOT(onReportSpamHide())); connect(&_reportSpamPanel, SIGNAL(hideClicked()), this, SLOT(onReportSpamHide()));
@ -2959,6 +2964,27 @@ void HistoryWidget::notifyUserIsBotChanged(UserData *user) {
} }
} }
void HistoryWidget::notifyMigrateUpdated(PeerData *peer) {
if (_peer) {
if (_peer == peer) {
if (peer->migrateTo()) {
showHistory(peer->migrateTo()->id, (_showAtMsgId > 0) ? (-_showAtMsgId) : _showAtMsgId, true);
} else if ((_migrated ? _migrated->peer : 0) != peer->migrateFrom()) {
History *migrated = peer->migrateFrom() ? App::history(peer->migrateFrom()->id) : 0;
if (_migrated || (migrated && migrated->unreadCount > 0)) {
showHistory(peer->id, peer->migrateFrom() ? _showAtMsgId : ((_showAtMsgId < 0 && -_showAtMsgId < ServerMaxMsgId) ? ShowAtUnreadMsgId : _showAtMsgId), true);
} else {
_migrated = migrated;
_list->notifyMigrateUpdated();
updateListSize();
}
}
} else if (_migrated && _migrated->peer == peer && peer->migrateTo() != _peer) {
showHistory(_peer->id, _showAtMsgId, true);
}
}
}
void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) { void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
cSetLastStickersUpdate(getms(true)); cSetLastStickersUpdate(getms(true));
_stickersUpdateRequest = 0; _stickersUpdateRequest = 0;
@ -3163,12 +3189,12 @@ void HistoryWidget::applyDraft(bool parseLinks) {
} }
} }
void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId) { void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool reload) {
MsgId wasMsgId = _showAtMsgId; MsgId wasMsgId = _showAtMsgId;
History *wasHistory = _history; History *wasHistory = _history;
if (_history) { if (_history) {
if (_peer->id == peerId) { if (_peer->id == peerId && !reload) {
_history->lastWidth = 0; _history->lastWidth = 0;
bool wasOnlyImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : true; bool wasOnlyImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : true;
@ -3423,9 +3449,20 @@ void HistoryWidget::updateReportSpamStatus() {
_reportSpamStatus = i.value(); _reportSpamStatus = i.value();
_reportSpamPanel.setReported(_reportSpamStatus == dbiprsReportSent, _peer); _reportSpamPanel.setReported(_reportSpamStatus == dbiprsReportSent, _peer);
return; return;
} else if (_peer->migrateFrom()) { // migrate report status
i = cReportSpamStatuses().constFind(_peer->migrateFrom()->id);
if (i != cReportSpamStatuses().cend()) {
_reportSpamStatus = i.value();
_reportSpamPanel.setReported(_reportSpamStatus == dbiprsReportSent, _peer);
cRefReportSpamStatuses().insert(_peer->id, _reportSpamStatus);
Local::writeReportSpamStatuses();
return;
}
} }
} }
if ((!_history->loadedAtTop() && (_history->blocks.size() < 2 || (_history->blocks.size() == 2 && _history->blocks.at(1)->items.size() < 2))) || !cContactsReceived() || _firstLoadRequest) { if (!cContactsReceived() || _firstLoadRequest) {
_reportSpamStatus = dbiprsUnknown;
} else if (!_history->loadedAtTop() && (_history->blocks.size() < 2 || (_history->blocks.size() == 2 && _history->blocks.at(1)->items.size() < 2))) {
_reportSpamStatus = dbiprsUnknown; _reportSpamStatus = dbiprsUnknown;
} else if (_peer->isUser()) { } else if (_peer->isUser()) {
if (_peer->asUser()->contact > 0) { if (_peer->asUser()->contact > 0) {
@ -3463,7 +3500,18 @@ void HistoryWidget::updateReportSpamStatus() {
_reportSpamStatus = dbiprsNoButton; _reportSpamStatus = dbiprsNoButton;
} }
} else if (_peer->isChannel()) { } else if (_peer->isChannel()) {
if (!_peer->asChannel()->inviter || _history->asChannelHistory()->maxReadMessageDate().isNull()) { if (_peer->migrateFrom() && _peer->migrateFrom()->isChat()) {
if (_peer->migrateFrom()->asChat()->inviterForSpamReport > 0) {
UserData *user = App::userLoaded(_peer->migrateFrom()->asChat()->inviterForSpamReport);
if (user && user->contact > 0) {
_reportSpamStatus = dbiprsNoButton;
} else {
_reportSpamStatus = dbiprsShowButton;
}
} else {
_reportSpamStatus = dbiprsNoButton;
}
} else if (!_peer->asChannel()->inviter || _history->asChannelHistory()->maxReadMessageDate().isNull()) {
_reportSpamStatus = dbiprsUnknown; _reportSpamStatus = dbiprsUnknown;
} else if (_peer->asChannel()->inviter > 0) { } else if (_peer->asChannel()->inviter > 0) {
UserData *user = App::userLoaded(_peer->asChannel()->inviter); UserData *user = App::userLoaded(_peer->asChannel()->inviter);
@ -5518,6 +5566,9 @@ void HistoryWidget::onReportSpamClear() {
MTP::send(MTPmessages_DeleteChatUser(_clearPeer->asChat()->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _clearPeer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _clearPeer)); MTP::send(MTPmessages_DeleteChatUser(_clearPeer->asChat()->inputChat, App::self()->inputUser), App::main()->rpcDone(&MainWidget::deleteHistoryAfterLeave, _clearPeer), App::main()->rpcFail(&MainWidget::leaveChatFailed, _clearPeer));
} else if (_clearPeer->isChannel()) { } else if (_clearPeer->isChannel()) {
App::main()->showDialogs(); App::main()->showDialogs();
if (_clearPeer->migrateFrom()) {
App::main()->deleteConversation(_clearPeer->migrateFrom());
}
MTP::send(MTPchannels_LeaveChannel(_clearPeer->asChannel()->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived)); MTP::send(MTPchannels_LeaveChannel(_clearPeer->asChannel()->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived));
} }
} }

View File

@ -96,6 +96,7 @@ public:
int32 itemTop(const HistoryItem *item) const; // -1 if should not be visible, -2 if bad history() int32 itemTop(const HistoryItem *item) const; // -1 if should not be visible, -2 if bad history()
void notifyIsBotChanged(); void notifyIsBotChanged();
void notifyMigrateUpdated();
~HistoryInner(); ~HistoryInner();
@ -528,7 +529,7 @@ public:
void fastShowAtEnd(History *h); void fastShowAtEnd(History *h);
void applyDraft(bool parseLinks = true); void applyDraft(bool parseLinks = true);
void showHistory(const PeerId &peer, MsgId showAtMsgId); void showHistory(const PeerId &peer, MsgId showAtMsgId, bool reload = false);
void clearDelayedShowAt(); void clearDelayedShowAt();
void clearAllLoadRequests(); void clearAllLoadRequests();
@ -559,6 +560,7 @@ public:
void notifyBotCommandsChanged(UserData *user); void notifyBotCommandsChanged(UserData *user);
void notifyUserIsBotChanged(UserData *user); void notifyUserIsBotChanged(UserData *user);
void notifyMigrateUpdated(PeerData *peer);
~HistoryWidget(); ~HistoryWidget();
@ -654,6 +656,7 @@ public slots:
void onDraftSave(bool delayed = false); void onDraftSave(bool delayed = false);
void updateStickers(); void updateStickers();
void updateField();
void onRecordError(); void onRecordError();
void onRecordDone(QByteArray result, qint32 samples); void onRecordDone(QByteArray result, qint32 samples);
@ -671,7 +674,6 @@ private:
void drawField(Painter &p); void drawField(Painter &p);
void drawRecordButton(Painter &p); void drawRecordButton(Painter &p);
void drawRecording(Painter &p); void drawRecording(Painter &p);
void updateField();
DBIPeerReportSpamStatus _reportSpamStatus; DBIPeerReportSpamStatus _reportSpamStatus;
void updateReportSpamStatus(); void updateReportSpamStatus();

View File

@ -682,12 +682,16 @@ void MainWidget::updateStickers() {
history.updateStickers(); history.updateStickers();
} }
void MainWidget::notifyBotCommandsChanged(UserData *bot) {
history.notifyBotCommandsChanged(bot);
}
void MainWidget::notifyUserIsBotChanged(UserData *bot) { void MainWidget::notifyUserIsBotChanged(UserData *bot) {
history.notifyUserIsBotChanged(bot); history.notifyUserIsBotChanged(bot);
} }
void MainWidget::notifyBotCommandsChanged(UserData *bot) { void MainWidget::notifyMigrateUpdated(PeerData *peer) {
history.notifyBotCommandsChanged(bot); history.notifyMigrateUpdated(peer);
} }
void MainWidget::onUpdateMuted() { void MainWidget::onUpdateMuted() {
@ -919,6 +923,15 @@ void MainWidget::deleteConversation(PeerData *peer, bool deleteHistory) {
} }
if (History *h = App::historyLoaded(peer->id)) { if (History *h = App::historyLoaded(peer->id)) {
removeDialog(h); removeDialog(h);
if (peer->isMegagroup() && peer->asChannel()->mgInfo->migrateFromPtr) {
if (History *migrated = App::historyLoaded(peer->asChannel()->mgInfo->migrateFromPtr->id)) {
if (migrated->lastMsg) { // return initial dialog
migrated->setLastMessage(migrated->lastMsg);
} else {
checkPeerHistory(migrated->peer);
}
}
}
h->clear(); h->clear();
h->newLoaded = true; h->newLoaded = true;
h->oldLoaded = deleteHistory; h->oldLoaded = deleteHistory;

View File

@ -386,6 +386,7 @@ public:
void updateStickers(); void updateStickers();
void notifyBotCommandsChanged(UserData *bot); void notifyBotCommandsChanged(UserData *bot);
void notifyUserIsBotChanged(UserData *bot); void notifyUserIsBotChanged(UserData *bot);
void notifyMigrateUpdated(PeerData *peer);
void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory
void clearBotStartToken(PeerData *peer); void clearBotStartToken(PeerData *peer);

View File

@ -2007,6 +2007,11 @@ void OverviewInner::switchType(MediaOverviewType type) {
} else { } else {
_search.hide(); _search.hide();
} }
if (!_search.getLastText().isEmpty()) {
_search.setText(QString());
_search.updatePlaceholder();
onSearchUpdate();
}
_cancelSearch.hide(); _cancelSearch.hide();
} }
mediaOverviewUpdated(); mediaOverviewUpdated();
@ -2146,7 +2151,7 @@ void OverviewInner::onNeedSearchMessages() {
} }
void OverviewInner::onSearchUpdate() { void OverviewInner::onSearchUpdate() {
QString filterText = _search.text().trimmed(); QString filterText = (_type == OverviewLinks) ? _search.text().trimmed() : QString();
bool inSearch = !filterText.isEmpty(), changed = (inSearch != _inSearch); bool inSearch = !filterText.isEmpty(), changed = (inSearch != _inSearch);
_inSearch = inSearch; _inSearch = inSearch;

View File

@ -535,7 +535,7 @@ void ProfileInner::onFullPeerUpdated(PeerData *peer) {
} }
} else if (_peerChat) { } else if (_peerChat) {
updateInvitationLink(); updateInvitationLink();
_showMigrate = (_peerChat && _amCreator && !_peerChat->isMigrated() && _peerChat->count >= 3); _showMigrate = (_peerChat && _amCreator && !_peerChat->isMigrated() && _peerChat->count >= cMaxGroupCount());
showAll(); showAll();
resizeEvent(0); resizeEvent(0);
_admins.setText(lng_channel_admins_link(lt_count, _peerChat->adminsEnabled() ? (_peerChat->admins.size() + 1) : 0)); _admins.setText(lng_channel_admins_link(lt_count, _peerChat->adminsEnabled() ? (_peerChat->admins.size() + 1) : 0));
@ -595,7 +595,7 @@ void ProfileInner::peerUpdated(PeerData *data) {
} else if (_peerChat) { } else if (_peerChat) {
if (_peerChat->photoId && _peerChat->photoId != UnknownPeerPhotoId) photo = App::photo(_peerChat->photoId); if (_peerChat->photoId && _peerChat->photoId != UnknownPeerPhotoId) photo = App::photo(_peerChat->photoId);
_admins.setText(lng_channel_admins_link(lt_count, _peerChat->adminsEnabled() ? (_peerChat->admins.size() + 1) : 0)); _admins.setText(lng_channel_admins_link(lt_count, _peerChat->adminsEnabled() ? (_peerChat->admins.size() + 1) : 0));
_showMigrate = (_peerChat && _amCreator && !_peerChat->isMigrated() && _peerChat->count >= 3); _showMigrate = (_peerChat && _amCreator && !_peerChat->isMigrated() && _peerChat->count >= cMaxGroupCount());
if (App::main()) App::main()->topBar()->showAll(); if (App::main()) App::main()->topBar()->showAll();
} else if (_peerChannel) { } else if (_peerChannel) {
if (_peerChannel->photoId && _peerChannel->photoId != UnknownPeerPhotoId) photo = App::photo(_peerChannel->photoId); if (_peerChannel->photoId && _peerChannel->photoId != UnknownPeerPhotoId) photo = App::photo(_peerChannel->photoId);

View File

@ -526,7 +526,7 @@ private:
}; };
struct MegagroupInfo { struct MegagroupInfo {
MegagroupInfo() : botStatus(0), migrateFromPtr(0), lastParticipantsStatus(LastParticipantsUpToDate), lastParticipantsCount(0) { MegagroupInfo() : botStatus(0), joinedMessageFound(false), migrateFromPtr(0), lastParticipantsStatus(LastParticipantsUpToDate), lastParticipantsCount(0) {
} }
typedef QList<UserData*> LastParticipants; typedef QList<UserData*> LastParticipants;
LastParticipants lastParticipants; LastParticipants lastParticipants;
@ -538,6 +538,8 @@ struct MegagroupInfo {
Bots bots; Bots bots;
int32 botStatus; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other int32 botStatus; // -1 - no bots, 0 - unknown, 1 - one bot, that sees all history, 2 - other
bool joinedMessageFound;
enum LastParticipantsStatus { enum LastParticipantsStatus {
LastParticipantsUpToDate = 0x00, LastParticipantsUpToDate = 0x00,
LastParticipantsAdminsOutdated = 0x01, LastParticipantsAdminsOutdated = 0x01,

View File

@ -980,7 +980,7 @@ QRect Window::iconRect() const {
bool Window::eventFilter(QObject *obj, QEvent *evt) { bool Window::eventFilter(QObject *obj, QEvent *evt) {
QEvent::Type t = evt->type(); QEvent::Type t = evt->type();
if (t == QEvent::MouseButtonPress || t == QEvent::KeyPress || t == QEvent::TouchBegin) { if (t == QEvent::MouseButtonPress || t == QEvent::KeyPress || t == QEvent::TouchBegin || t == QEvent::Wheel) {
psUserActionDone(); psUserActionDone();
} else if (t == QEvent::MouseMove) { } else if (t == QEvent::MouseMove) {
if (main && main->isIdle()) { if (main && main->isIdle()) {