This commit is contained in:
John Preston 2015-12-25 00:32:55 +03:00
commit 3555710d67
1 changed files with 16 additions and 12 deletions

View File

@ -624,7 +624,7 @@ void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) { for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) {
(*i)->y += dh; (*i)->y += dh;
} }
blocks.push_front(dateBlock); // date block blocks.push_front(dateBlock); // date block CHECK
height += dh; height += dh;
} }
} }
@ -719,7 +719,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
} }
} }
if (!block->items.isEmpty()) { if (!block->items.isEmpty()) {
blocks.push_front(block); blocks.push_front(block); // CHECK
if (width) { if (width) {
addToH += block->height; addToH += block->height;
++skip; ++skip;
@ -740,7 +740,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
addToH += dh; addToH += dh;
++skip; ++skip;
} }
blocks.push_front(dateBlock); // date block blocks.push_front(dateBlock); // date block CHECK
} }
if (width && addToH) { if (width && addToH) {
for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) { for (Blocks::iterator i = blocks.begin(), e = blocks.end(); i != e; ++i) {
@ -945,7 +945,7 @@ void ChannelHistory::switchMode() {
item->attach(block); item->attach(block);
prev = addItemAfterPrevToBlock(item, prev, block); prev = addItemAfterPrevToBlock(item, prev, block);
} }
blocks.push_back(block); blocks.push_back(block); // CHECK
if (width) { if (width) {
block->y = height; block->y = height;
height += block->height; height += block->height;
@ -1326,13 +1326,10 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPMessage &msg, boo
HistoryItem *result = App::histItemById(channelId(), msgId); HistoryItem *result = App::histItemById(channelId(), msgId);
if (result) { if (result) {
if (block) { if (block) {
if (result->detached()) { if (!result->detached()) {
result->attach(block); result->detach();
} else if (result->block() != block) {
LOG(("App Error: createItem() called for existing item in other block!"));
result->destroy();
result = 0;
} }
result->attach(block);
} }
if (result) { if (result) {
if (msg.type() == mtpc_message) { if (msg.type() == mtpc_message) {
@ -1600,7 +1597,14 @@ HistoryItem *History::addNewMessage(const MTPMessage &msg, NewMessageType type)
} else { } else {
to = blocks.back(); to = blocks.back();
} }
return addNewItem(to, newBlock, createItem(to, msg, (type == NewMessageUnread)), (type == NewMessageUnread)); HistoryItem *item = createItem((type == NewMessageLast) ? 0 : to, msg, (type == NewMessageUnread));
if (type == NewMessageLast) {
if (!item->detached()) {
return item;
}
item->attach(to);
}
return addNewItem(to, newBlock, item, (type == NewMessageUnread));
} }
HistoryItem *History::addToHistory(const MTPMessage &msg) { HistoryItem *History::addToHistory(const MTPMessage &msg) {
@ -1862,7 +1866,7 @@ HistoryItem *History::addMessageGroupAfterPrev(HistoryItem *newItem, HistoryItem
createInitialDateBlock(date); createInitialDateBlock(date);
block = new HistoryBlock(this); block = new HistoryBlock(this);
blocks.push_back(block); blocks.push_back(block); // CHECK
if (width) { if (width) {
block->y = height; block->y = height;
} }