Removed legacy HistoryItem::type() code.

This commit is contained in:
John Preston 2017-02-10 17:16:50 +03:00
parent 2ab3cda743
commit c39bf239ea
12 changed files with 104 additions and 181 deletions

View File

@ -161,7 +161,7 @@ void ConfirmBox::mousePressEvent(QMouseEvent *e) {
void ConfirmBox::mouseReleaseEvent(QMouseEvent *e) {
_lastMousePos = e->globalPos();
updateHover();
if (ClickHandlerPtr activated = ClickHandler::unpressed()) {
if (auto activated = ClickHandler::unpressed()) {
Ui::hideLayer();
App::activateClickHandler(activated, e->button());
}

View File

@ -39,8 +39,8 @@ bool ClickHandler::setActive(const ClickHandlerPtr &p, ClickHandlerHost *host) {
// other pressed click handler currently, if there is
// this method will be called when it is unpressed
if (_active && *_active) {
bool emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active);
ClickHandlerPtr wasactive = *_active;
auto emitClickHandlerActiveChanged = (!_pressed || !*_pressed || *_pressed == *_active);
auto wasactive = *_active;
(*_active).clear();
if (_activeHost) {
if (emitClickHandlerActiveChanged) {

View File

@ -32,7 +32,6 @@ enum ExpandLinksMode {
class ClickHandlerHost {
protected:
virtual void clickHandlerActiveChanged(const ClickHandlerPtr &action, bool active) {
}
virtual void clickHandlerPressedChanged(const ClickHandlerPtr &action, bool pressed) {

View File

@ -349,17 +349,13 @@ bool History::updateSendActionNeedsAnimating(TimeMs ms, bool force) {
return result;
}
ChannelHistory::ChannelHistory(const PeerId &peer) : History(peer)
, _joinedMessage(nullptr) {
}
void ChannelHistory::getRangeDifference() {
MsgId fromId = 0, toId = 0;
for (int32 blockIndex = 0, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) {
HistoryBlock *block = blocks.at(blockIndex);
for (int32 itemIndex = 0, itemsCount = block->items.size(); itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex);
if (item->type() == HistoryItemMsg && item->id > 0) {
auto fromId = MsgId(0), toId = MsgId(0);
for (auto blockIndex = 0, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) {
auto block = blocks.at(blockIndex);
for (auto itemIndex = 0, itemsCount = block->items.size(); itemIndex < itemsCount; ++itemIndex) {
auto item = block->items.at(itemIndex);
if (item->id > 0) {
fromId = item->id;
break;
}
@ -367,11 +363,12 @@ void ChannelHistory::getRangeDifference() {
if (fromId) break;
}
if (!fromId) return;
for (int32 blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
if (item->type() == HistoryItemMsg && item->id > 0) {
for (auto blockIndex = blocks.size(); blockIndex > 0;) {
auto block = blocks.at(--blockIndex);
for (auto itemIndex = block->items.size(); itemIndex > 0;) {
auto item = block->items.at(--itemIndex);
if (item->id > 0) {
toId = item->id;
break;
}
@ -423,31 +420,29 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
return _joinedMessage;
}
for (int32 blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
HistoryItemType type = item->type();
if (type == HistoryItemMsg) {
// Due to a server bug sometimes inviteDate is less (before) than the
// first message in the megagroup (message about migration), let us
// ignore that and think, that the inviteDate is always greater-or-equal.
if (item->isGroupMigrate() && peer->isMegagroup() && peer->migrateFrom()) {
peer->asChannel()->mgInfo->joinedMessageFound = true;
return nullptr;
}
if (item->date <= inviteDate) {
++itemIndex;
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
addNewInTheMiddle(_joinedMessage, blockIndex, itemIndex);
if (lastMsgDate.isNull() || inviteDate >= lastMsgDate) {
setLastMessage(_joinedMessage);
if (unread) {
newItemAdded(_joinedMessage);
}
for (auto blockIndex = blocks.size(); blockIndex > 0;) {
auto block = blocks.at(--blockIndex);
for (auto itemIndex = block->items.size(); itemIndex > 0;) {
auto item = block->items.at(--itemIndex);
// Due to a server bug sometimes inviteDate is less (before) than the
// first message in the megagroup (message about migration), let us
// ignore that and think, that the inviteDate is always greater-or-equal.
if (item->isGroupMigrate() && peer->isMegagroup() && peer->migrateFrom()) {
peer->asChannel()->mgInfo->joinedMessageFound = true;
return nullptr;
}
if (item->date <= inviteDate) {
++itemIndex;
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
addNewInTheMiddle(_joinedMessage, blockIndex, itemIndex);
if (lastMsgDate.isNull() || inviteDate >= lastMsgDate) {
setLastMessage(_joinedMessage);
if (unread) {
newItemAdded(_joinedMessage);
}
return _joinedMessage;
}
return _joinedMessage;
}
}
}
@ -479,34 +474,10 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
QDateTime inviteDate = peer->asChannel()->inviteDate;
QDateTime firstDate, lastDate;
for (int blockIndex = 0, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) {
HistoryBlock *block = blocks.at(blockIndex);
int itemIndex = 0, itemsCount = block->items.size();
for (; itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex);
HistoryItemType type = item->type();
if (type == HistoryItemMsg) {
firstDate = item->date;
break;
}
}
if (itemIndex < itemsCount) break;
if (!blocks.isEmpty()) {
firstDate = blocks.front()->items.front()->date;
lastDate = blocks.back()->items.back()->date;
}
for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex);
int itemIndex = block->items.size();
for (; itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
HistoryItemType type = item->type();
if (type == HistoryItemMsg) {
lastDate = item->date;
++itemIndex;
break;
}
}
if (itemIndex) break;
}
if (!firstDate.isNull() && !lastDate.isNull() && (firstDate <= inviteDate || loadedAtTop()) && (lastDate > inviteDate || loadedAtBottom())) {
bool willBeLastMsg = (inviteDate >= lastDate);
if (insertJoinedMessage(createUnread && willBeLastMsg) && willBeLastMsg) {
@ -567,25 +538,6 @@ void ChannelHistory::cleared(bool leaveItems) {
_joinedMessage = nullptr;
}
HistoryItem *ChannelHistory::findPrevItem(HistoryItem *item) const {
if (item->detached()) return nullptr;
int itemIndex = item->indexInBlock();
int blockIndex = item->block()->indexInHistory();
for (++blockIndex, ++itemIndex; blockIndex > 0;) {
--blockIndex;
HistoryBlock *block = blocks.at(blockIndex);
if (!itemIndex) itemIndex = block->items.size();
for (; itemIndex > 0;) {
--itemIndex;
if (block->items.at(itemIndex)->type() == HistoryItemMsg) {
return block->items.at(itemIndex);
}
}
}
return nullptr;
}
void ChannelHistory::messageDetached(HistoryItem *msg) {
if (_joinedMessage == msg) {
_joinedMessage = nullptr;
@ -1415,7 +1367,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice) {
if (slice.isEmpty()) {
newLoaded = true;
if (!lastMsg) {
setLastMessage(lastImportantMessage());
setLastMessage(lastAvailableMessage());
}
}
@ -1433,7 +1385,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice) {
if (!atLeastOneAdded) {
newLoaded = true;
setLastMessage(lastImportantMessage());
setLastMessage(lastAvailableMessage());
}
}
@ -1452,7 +1404,7 @@ void History::checkLastMsg() {
checkAddAllToOverview();
}
} else if (newLoaded) {
setLastMessage(lastImportantMessage());
setLastMessage(lastAvailableMessage());
}
}
@ -1506,7 +1458,7 @@ void History::updateShowFrom() {
--i;
for (auto j = (*i)->items.cend(); j != (*i)->items.cbegin();) {
--j;
if ((*j)->type() == HistoryItemMsg && (*j)->id > 0 && (!(*j)->out() || !showFrom)) {
if ((*j)->id > 0 && (!(*j)->out() || !showFrom)) {
if ((*j)->id >= inboxReadBefore) {
showFrom = *j;
} else {
@ -1556,27 +1508,14 @@ MsgId History::outboxRead(HistoryItem *wasRead) {
return outboxRead(wasRead ? wasRead->id : 0);
}
HistoryItem *History::lastImportantMessage() const {
if (isEmpty()) {
return nullptr;
}
bool importantOnly = isChannel() && !isMegagroup();
for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex);
for (int itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
if (item->type() == HistoryItemMsg) {
return item;
}
}
}
return nullptr;
HistoryItem *History::lastAvailableMessage() const {
return isEmpty() ? nullptr : blocks.back()->items.back();
}
void History::setUnreadCount(int newUnreadCount) {
if (_unreadCount != newUnreadCount) {
if (newUnreadCount == 1) {
if (loadedAtBottom()) showFrom = lastImportantMessage();
if (loadedAtBottom()) showFrom = lastAvailableMessage();
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead());
} else if (!newUnreadCount) {
showFrom = nullptr;
@ -1626,19 +1565,19 @@ void History::setUnreadCount(int newUnreadCount) {
void History::getNextShowFrom(HistoryBlock *block, int i) {
if (i >= 0) {
int l = block->items.size();
auto l = block->items.size();
for (++i; i < l; ++i) {
if (block->items.at(i)->type() == HistoryItemMsg) {
if (block->items[i]->id > 0) {
showFrom = block->items.at(i);
return;
}
}
}
for (int j = block->indexInHistory() + 1, s = blocks.size(); j < s; ++j) {
for (auto j = block->indexInHistory() + 1, s = blocks.size(); j < s; ++j) {
block = blocks.at(j);
for_const (HistoryItem *item, block->items) {
if (item->type() == HistoryItemMsg) {
for_const (auto item, block->items) {
if (item->id > 0) {
showFrom = item;
return;
}
@ -1935,7 +1874,7 @@ void History::updateChatListSortPosition() {
}
void History::fixLastMessage(bool wasAtBottom) {
setLastMessage(wasAtBottom ? lastImportantMessage() : 0);
setLastMessage(wasAtBottom ? lastAvailableMessage() : 0);
}
MsgId History::minMsgId() const {

View File

@ -240,7 +240,7 @@ public:
MsgId outboxRead(MsgId upTo);
MsgId outboxRead(HistoryItem *wasRead);
HistoryItem *lastImportantMessage() const;
HistoryItem *lastAvailableMessage() const;
int unreadCount() const {
return _unreadCount;
@ -584,7 +584,7 @@ private:
class HistoryJoined;
class ChannelHistory : public History {
public:
ChannelHistory(const PeerId &peer);
using History::History;
void messageDetached(HistoryItem *msg);
@ -604,13 +604,11 @@ private:
void checkMaxReadMessageDate();
HistoryItem *findPrevItem(HistoryItem *item) const;
void cleared(bool leaveItems);
QDateTime _maxReadMessageDate;
HistoryJoined *_joinedMessage;
HistoryJoined *_joinedMessage = nullptr;
MsgId _rangeDifferenceFromId, _rangeDifferenceToId;
int32 _rangeDifferencePts;

View File

@ -650,7 +650,7 @@ void HistoryItem::destroy() {
// All this must be done for all items manually in History::clear(false)!
eraseFromOverview();
bool wasAtBottom = history()->loadedAtBottom();
auto wasAtBottom = history()->loadedAtBottom();
_history->removeNotification(this);
detach();
if (history()->isChannel()) {

View File

@ -101,11 +101,6 @@ enum InfoDisplayType {
InfoDisplayOverBackground,
};
enum HistoryItemType {
HistoryItemMsg = 0,
HistoryItemJoined
};
struct HistoryMessageVia : public RuntimeComponent<HistoryMessageVia> {
void create(int32 userId);
void resize(int32 availw) const;
@ -630,9 +625,6 @@ public:
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
virtual HistoryItemType type() const {
return HistoryItemMsg;
}
virtual bool serviceMsg() const {
return false;
}
@ -687,7 +679,7 @@ public:
}
bool canDelete() const {
ChannelData *channel = _history->peer->asChannel();
auto channel = _history->peer->asChannel();
if (!channel) return !(_flags & MTPDmessage_ClientFlag::f_is_group_migrate);
if (id == 1) return false;
@ -707,7 +699,7 @@ public:
bool canDeleteForEveryone(const QDateTime &cur) const;
bool suggestBanReportDeleteAll() const {
ChannelData *channel = history()->peer->asChannel();
auto channel = history()->peer->asChannel();
if (!channel || (!channel->amEditor() && !channel->amCreator())) return false;
return !isPost() && !out() && from()->isUser() && toHistoryMessage();
}

View File

@ -357,10 +357,6 @@ public:
return _create(history, date, from, flags);
}
HistoryItemType type() const {
return HistoryItemJoined;
}
protected:
HistoryJoined(History *history, const QDateTime &date, UserData *from, MTPDmessage::Flags flags);
using HistoryItemInstantiated<HistoryJoined>::_create;

View File

@ -989,7 +989,7 @@ void HistoryInner::onDragExec() {
}
}
}
ClickHandlerPtr pressedHandler = ClickHandler::getPressed();
auto pressedHandler = ClickHandler::getPressed();
TextWithEntities sel;
QList<QUrl> urls;
if (uponSelected) {
@ -1004,7 +1004,7 @@ void HistoryInner::onDragExec() {
updateDragSelection(0, 0, false);
_widget->noSelectingScroll();
QDrag *drag = new QDrag(App::wnd());
auto drag = std_::make_unique<QDrag>(App::wnd());
if (!urls.isEmpty()) mimeData->setUrls(urls);
if (uponSelected && !_selected.isEmpty() && _selected.cbegin().value() == FullSelection && !Adaptive::OneColumn()) {
mimeData->setData(qsl("application/x-td-forward-selected"), "1");
@ -1017,15 +1017,15 @@ void HistoryInner::onDragExec() {
if (App::main()) App::main()->updateAfterDrag();
return;
} else {
QString forwardMimeType;
HistoryMedia *pressedMedia = nullptr;
if (HistoryItem *pressedItem = App::pressedItem()) {
auto forwardMimeType = QString();
auto pressedMedia = static_cast<HistoryMedia*>(nullptr);
if (auto pressedItem = App::pressedItem()) {
pressedMedia = pressedItem->getMedia();
if (_dragCursorState == HistoryInDateCursorState || (pressedMedia && pressedMedia->dragItem())) {
forwardMimeType = qsl("application/x-td-forward-pressed");
}
}
if (HistoryItem *pressedLnkItem = App::pressedLinkItem()) {
if (auto pressedLnkItem = App::pressedLinkItem()) {
if ((pressedMedia = pressedLnkItem->getMedia())) {
if (forwardMimeType.isEmpty() && pressedMedia->dragItemByHandler(pressedHandler)) {
forwardMimeType = qsl("application/x-td-forward-pressed-link");
@ -1033,12 +1033,12 @@ void HistoryInner::onDragExec() {
}
}
if (!forwardMimeType.isEmpty()) {
QDrag *drag = new QDrag(App::wnd());
QMimeData *mimeData = new QMimeData();
auto drag = std_::make_unique<QDrag>(App::wnd());
auto mimeData = std_::make_unique<QMimeData>();
mimeData->setData(forwardMimeType, "1");
if (DocumentData *document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
QString filepath = document->filepath(DocumentData::FilePathResolveChecked);
if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
auto filepath = document->filepath(DocumentData::FilePathResolveChecked);
if (!filepath.isEmpty()) {
QList<QUrl> urls;
urls.push_back(QUrl::fromLocalFile(filepath));
@ -1046,7 +1046,7 @@ void HistoryInner::onDragExec() {
}
}
drag->setMimeData(mimeData);
drag->setMimeData(mimeData.release());
drag->exec(Qt::CopyAction);
// We don't receive mouseReleaseEvent when drag is finished.
@ -1315,8 +1315,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
App::contextItem(App::hoveredLinkItem());
}
} else { // maybe cursor on some text history item?
bool canDelete = (item && item->type() == HistoryItemMsg) && item->canDelete();
bool canForward = (item && item->type() == HistoryItemMsg) && (item->id > 0) && !item->serviceMsg();
bool canDelete = item && item->canDelete() && (item->id > 0 || !item->serviceMsg());
bool canForward = item && (item->id > 0) && !item->serviceMsg();
HistoryMessage *msg = dynamic_cast<HistoryMessage*>(item);
if (isUponSelected > 0) {
@ -1835,7 +1835,7 @@ void HistoryInner::enterEvent(QEvent *e) {
}
void HistoryInner::leaveEvent(QEvent *e) {
if (HistoryItem *item = App::hoveredItem()) {
if (auto item = App::hoveredItem()) {
repaintItem(item);
App::hoveredItem(nullptr);
}
@ -1948,8 +1948,8 @@ bool HistoryInner::canDeleteSelected() const {
void HistoryInner::getSelectionState(int32 &selectedForForward, int32 &selectedForDelete) const {
selectedForForward = selectedForDelete = 0;
for (SelectedItems::const_iterator i = _selected.cbegin(), e = _selected.cend(); i != e; ++i) {
if (i.key()->type() == HistoryItemMsg && i.value() == FullSelection) {
for (auto i = _selected.cbegin(), e = _selected.cend(); i != e; ++i) {
if (i.value() == FullSelection) {
if (i.key()->canDelete()) {
++selectedForDelete;
}
@ -2005,8 +2005,8 @@ void HistoryInner::onUpdateSelected() {
return;
}
QPoint mousePos(mapFromGlobal(_dragPos));
QPoint point(_widget->clampMousePosition(mousePos));
auto mousePos = mapFromGlobal(_dragPos);
auto point = _widget->clampMousePosition(mousePos);
HistoryBlock *block = 0;
HistoryItem *item = 0;
@ -6180,15 +6180,15 @@ void HistoryWidget::contextMenuEvent(QContextMenuEvent *e) {
}
void HistoryWidget::forwardMessage() {
HistoryItem *item = App::contextItem();
if (!item || item->type() != HistoryItemMsg || item->serviceMsg()) return;
auto item = App::contextItem();
if (!item || item->id < 0 || item->serviceMsg()) return;
App::main()->forwardLayer();
}
void HistoryWidget::selectMessage() {
HistoryItem *item = App::contextItem();
if (!item || item->type() != HistoryItemMsg || item->serviceMsg()) return;
auto item = App::contextItem();
if (!item || item->id < 0 || item->serviceMsg()) return;
if (_list) _list->selectItem(item);
}
@ -7861,12 +7861,12 @@ void HistoryWidget::onReplyToMessage() {
onReplyToMessage();
App::contextItem(to);
} else {
if (to->type() != HistoryItemMsg || to->serviceMsg()) {
if (to->id < 0 || to->serviceMsg()) {
Ui::show(Box<InformBox>(lang(lng_reply_cant)));
} else {
Ui::show(Box<ConfirmBox>(lang(lng_reply_cant_forward), lang(lng_selected_forward), base::lambda_guarded(this, [this] {
auto item = App::contextItem();
if (!item || item->type() != HistoryItemMsg || item->serviceMsg()) return;
if (!item || item->id < 0 || item->serviceMsg()) return;
App::forward(_peer->id, ForwardContextMessage);
})));
@ -8381,7 +8381,7 @@ void HistoryWidget::onForwardSelected() {
void HistoryWidget::confirmDeleteContextItem() {
auto item = App::contextItem();
if (!item || item->type() != HistoryItemMsg) return;
if (!item) return;
if (auto message = item->toHistoryMessage()) {
if (message->uploading()) {
@ -8406,7 +8406,7 @@ void HistoryWidget::deleteContextItem(bool forEveryone) {
Ui::hideLayer();
auto item = App::contextItem();
if (!item || item->type() != HistoryItemMsg) {
if (!item) {
return;
}

View File

@ -881,16 +881,16 @@ void MainWidget::deleteAllFromUser(ChannelData *channel, UserData *from) {
t_assert(channel != nullptr && from != nullptr);
QVector<MsgId> toDestroy;
if (History *history = App::historyLoaded(channel->id)) {
for (HistoryBlock *block : history->blocks) {
for (HistoryItem *item : block->items) {
if (item->from() == from && item->type() == HistoryItemMsg && item->canDelete()) {
if (auto history = App::historyLoaded(channel->id)) {
for_const (auto block, history->blocks) {
for_const (auto item, block->items) {
if (item->from() == from && item->canDelete()) {
toDestroy.push_back(item->id);
}
}
}
for (const MsgId &msgId : toDestroy) {
if (HistoryItem *item = App::histItemById(peerToChannel(channel->id), msgId)) {
for_const (auto &msgId, toDestroy) {
if (auto item = App::histItemById(peerToChannel(channel->id), msgId)) {
item->destroy();
}
}
@ -3867,17 +3867,17 @@ void MainWidget::onFullPeerUpdated(PeerData *peer) {
}
void MainWidget::onSelfParticipantUpdated(ChannelData *channel) {
History *h = App::historyLoaded(channel->id);
auto history = App::historyLoaded(channel->id);
if (_updatedChannels.contains(channel)) {
_updatedChannels.remove(channel);
if ((h ? h : App::history(channel->id))->isEmpty()) {
if ((history ? history : App::history(channel->id))->isEmpty()) {
checkPeerHistory(channel);
} else {
h->asChannelHistory()->checkJoinedMessage(true);
history->asChannelHistory()->checkJoinedMessage(true);
_history->peerMessagesUpdated(channel->id);
}
} else if (h) {
h->asChannelHistory()->checkJoinedMessage();
} else if (history) {
history->asChannelHistory()->checkJoinedMessage();
_history->peerMessagesUpdated(channel->id);
}
}

View File

@ -1142,9 +1142,8 @@ void OverviewInner::enterEvent(QEvent *e) {
}
void OverviewInner::leaveEvent(QEvent *e) {
if (_selectedMsgId) {
repaintItem(_selectedMsgId, -1);
_selectedMsgId = 0;
if (auto selectedMsgId = base::take(_selectedMsgId)) {
repaintItem(selectedMsgId, -1);
}
ClickHandler::clearActive();
if (!ClickHandler::getPressed() && _cursor != style::cur_default) {
@ -1406,8 +1405,8 @@ void OverviewInner::goToMessage() {
}
void OverviewInner::forwardMessage() {
HistoryItem *item = App::contextItem();
if (!item || item->type() != HistoryItemMsg || item->serviceMsg()) return;
auto item = App::contextItem();
if (!item || item->id < 0) return;
App::main()->forwardLayer();
}
@ -1417,8 +1416,8 @@ MsgId OverviewInner::complexMsgId(const HistoryItem *item) const {
}
void OverviewInner::selectMessage() {
HistoryItem *item = App::contextItem();
if (!item || item->type() != HistoryItemMsg || item->serviceMsg()) return;
auto item = App::contextItem();
if (!item || item->id < 0) return;
if (!_selected.isEmpty() && _selected.cbegin().value() != FullSelection) {
_selected.clear();
@ -2274,7 +2273,7 @@ void OverviewWidget::onForwardSelected() {
void OverviewWidget::confirmDeleteContextItem() {
auto item = App::contextItem();
if (!item || item->type() != HistoryItemMsg) return;
if (!item) return;
if (auto message = item->toHistoryMessage()) {
if (message->uploading()) {
@ -2297,7 +2296,7 @@ void OverviewWidget::deleteContextItem(bool forEveryone) {
Ui::hideLayer();
auto item = App::contextItem();
if (!item || item->type() != HistoryItemMsg) {
if (!item) {
return;
}

View File

@ -1861,6 +1861,6 @@ ClickHandlerPtr peerOpenClickHandler(PeerData *peer) {
MsgId clientMsgId() {
static MsgId currentClientMsgId = StartClientMsgId;
Q_ASSERT(currentClientMsgId < EndClientMsgId);
t_assert(currentClientMsgId < EndClientMsgId);
return currentClientMsgId++;
}