mirror of https://github.com/procxx/kepka.git
Merge commit 'b32c6566ffe839025' into dev
This commit is contained in:
commit
42ded6ade9
|
@ -1788,7 +1788,6 @@ namespace App {
|
||||||
if (App::wnd()) {
|
if (App::wnd()) {
|
||||||
App::wnd()->notifyItemRemoved(item);
|
App::wnd()->notifyItemRemoved(item);
|
||||||
}
|
}
|
||||||
item->history()->setPendingResize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void historyUnregItem(HistoryItem *item) {
|
void historyUnregItem(HistoryItem *item) {
|
||||||
|
|
|
@ -1138,6 +1138,10 @@ void Histories::clear() {
|
||||||
for (Map::const_iterator i = map.cbegin(), e = map.cend(); i != e; ++i) {
|
for (Map::const_iterator i = map.cbegin(), e = map.cend(); i != e; ++i) {
|
||||||
delete i.value();
|
delete i.value();
|
||||||
}
|
}
|
||||||
|
_unreadFull = _unreadMuted = 0;
|
||||||
|
if (App::wnd()) {
|
||||||
|
App::wnd()->updateCounter();
|
||||||
|
}
|
||||||
App::historyClearItems();
|
App::historyClearItems();
|
||||||
typing.clear();
|
typing.clear();
|
||||||
map.clear();
|
map.clear();
|
||||||
|
@ -1999,7 +2003,7 @@ void History::setUnreadCount(int newUnreadCount, bool psUpdate) {
|
||||||
if (loadedAtBottom()) showFrom = lastImportantMessage();
|
if (loadedAtBottom()) showFrom = lastImportantMessage();
|
||||||
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead());
|
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead());
|
||||||
} else if (!newUnreadCount) {
|
} else if (!newUnreadCount) {
|
||||||
showFrom = 0;
|
showFrom = nullptr;
|
||||||
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead() + 1);
|
inboxReadBefore = qMax(inboxReadBefore, msgIdForRead() + 1);
|
||||||
}
|
}
|
||||||
if (inChatList()) {
|
if (inChatList()) {
|
||||||
|
@ -2564,8 +2568,6 @@ void History::changeMsgId(MsgId oldId, MsgId newId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::removeBlock(HistoryBlock *block) {
|
void History::removeBlock(HistoryBlock *block) {
|
||||||
setPendingResize();
|
|
||||||
|
|
||||||
t_assert(block->items.isEmpty());
|
t_assert(block->items.isEmpty());
|
||||||
|
|
||||||
int index = block->indexInHistory();
|
int index = block->indexInHistory();
|
||||||
|
@ -2576,7 +2578,6 @@ void History::removeBlock(HistoryBlock *block) {
|
||||||
if (index < blocks.size()) {
|
if (index < blocks.size()) {
|
||||||
blocks.at(index)->items.front()->previousItemChanged();
|
blocks.at(index)->items.front()->previousItemChanged();
|
||||||
}
|
}
|
||||||
delete block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
History::~History() {
|
History::~History() {
|
||||||
|
@ -2684,26 +2685,26 @@ void HistoryBlock::removeItem(HistoryItem *item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// blockIndex can be invalid now, because of destroying previous blocks
|
|
||||||
|
// itemIndex/blockIndex can be invalid now, because of destroying previous items/blocks
|
||||||
blockIndex = indexInHistory();
|
blockIndex = indexInHistory();
|
||||||
itemIndex = item->indexInBlock();
|
itemIndex = item->indexInBlock();
|
||||||
|
|
||||||
|
item->detachFast();
|
||||||
items.remove(itemIndex);
|
items.remove(itemIndex);
|
||||||
for (int i = itemIndex, l = items.size(); i < l; ++i) {
|
for (int i = itemIndex, l = items.size(); i < l; ++i) {
|
||||||
items.at(i)->setIndexInBlock(i);
|
items.at(i)->setIndexInBlock(i);
|
||||||
}
|
}
|
||||||
if (itemIndex < items.size()) {
|
if (items.isEmpty()) {
|
||||||
|
history->removeBlock(this);
|
||||||
|
} else if (itemIndex < items.size()) {
|
||||||
items.at(itemIndex)->previousItemChanged();
|
items.at(itemIndex)->previousItemChanged();
|
||||||
} else if (_indexInHistory + 1 < history->blocks.size()) {
|
} else if (blockIndex + 1 < history->blocks.size()) {
|
||||||
history->blocks.at(_indexInHistory + 1)->items.front()->previousItemChanged();
|
history->blocks.at(blockIndex + 1)->items.front()->previousItemChanged();
|
||||||
}
|
|
||||||
|
|
||||||
if ((!item->out() || item->isPost()) && item->unread() && history->unreadCount) {
|
|
||||||
history->setUnreadCount(history->unreadCount - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.isEmpty()) {
|
if (items.isEmpty()) {
|
||||||
history->removeBlock(this);
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2796,6 +2797,9 @@ void HistoryItem::destroy() {
|
||||||
history()->clearLastKeyboard();
|
history()->clearLastKeyboard();
|
||||||
if (App::main()) App::main()->updateBotKeyboard(history());
|
if (App::main()) App::main()->updateBotKeyboard(history());
|
||||||
}
|
}
|
||||||
|
if ((!out() || isPost()) && unread() && history()->unreadCount > 0) {
|
||||||
|
history()->setUnreadCount(history()->unreadCount - 1);
|
||||||
|
}
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2806,7 +2810,6 @@ void HistoryItem::detach() {
|
||||||
_history->asChannelHistory()->messageDetached(this);
|
_history->asChannelHistory()->messageDetached(this);
|
||||||
}
|
}
|
||||||
_block->removeItem(this);
|
_block->removeItem(this);
|
||||||
detachFast();
|
|
||||||
App::historyItemDetached(this);
|
App::historyItemDetached(this);
|
||||||
|
|
||||||
_history->setPendingResize();
|
_history->setPendingResize();
|
||||||
|
|
|
@ -239,7 +239,6 @@ public:
|
||||||
return blocks.isEmpty();
|
return blocks.isEmpty();
|
||||||
}
|
}
|
||||||
void clear(bool leaveItems = false);
|
void clear(bool leaveItems = false);
|
||||||
void removeBlock(HistoryBlock *block);
|
|
||||||
|
|
||||||
virtual ~History();
|
virtual ~History();
|
||||||
|
|
||||||
|
@ -498,11 +497,16 @@ private:
|
||||||
MediaOverviewIds overviewIds[OverviewCount];
|
MediaOverviewIds overviewIds[OverviewCount];
|
||||||
int32 overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded
|
int32 overviewCountData[OverviewCount]; // -1 - not loaded, 0 - all loaded, > 0 - count, but not all loaded
|
||||||
|
|
||||||
void clearBlocks(bool leaveItems);
|
|
||||||
|
|
||||||
friend class HistoryBlock;
|
friend class HistoryBlock;
|
||||||
friend class ChannelHistory;
|
friend class ChannelHistory;
|
||||||
|
|
||||||
|
// this method just removes a block from the blocks list
|
||||||
|
// when the last item from this block was detached and
|
||||||
|
// calls the required previousItemChanged()
|
||||||
|
void removeBlock(HistoryBlock *block);
|
||||||
|
|
||||||
|
void clearBlocks(bool leaveItems);
|
||||||
|
|
||||||
HistoryItem *createItem(const MTPMessage &msg, bool applyServiceAction, bool detachExistingItem);
|
HistoryItem *createItem(const MTPMessage &msg, bool applyServiceAction, bool detachExistingItem);
|
||||||
HistoryItem *createItemForwarded(MsgId id, MTPDmessage::Flags flags, QDateTime date, int32 from, HistoryMessage *msg);
|
HistoryItem *createItemForwarded(MsgId id, MTPDmessage::Flags flags, QDateTime date, int32 from, HistoryMessage *msg);
|
||||||
HistoryItem *createItemDocument(MsgId id, MTPDmessage::Flags flags, int32 viaBotId, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption);
|
HistoryItem *createItemDocument(MsgId id, MTPDmessage::Flags flags, int32 viaBotId, MsgId replyTo, QDateTime date, int32 from, DocumentData *doc, const QString &caption);
|
||||||
|
|
Loading…
Reference in New Issue