Skip to content

Commit

Permalink
Fixed collapse button style (looks like service message now).
Browse files Browse the repository at this point in the history
Added some asserts because of unknown crash in switch in channel.
  • Loading branch information
john-preston committed Mar 25, 2016
1 parent 844e375 commit 3132e4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Telegram/Resources/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ collapseButton: flatButton(btnDefFlat) {
textTop: 3px;
overTextTop: 3px;
downTextTop: 3px;
height: 24px;
height: 25px;
}
collapseHideDuration: 200;
collapseShowDuration: 200;
Expand Down
24 changes: 15 additions & 9 deletions Telegram/SourceFiles/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@ void ChannelHistory::switchMode() {
int willAddToBlock = qMin(int(MessagesPerPage), count - i);
block->items.reserve(willAddToBlock);
for (int till = i + willAddToBlock; i < till; ++i) {
t_assert(_otherList.at(i)->detached());
addItemToBlock(_otherList.at(i), block);
}

Expand Down Expand Up @@ -2565,6 +2566,8 @@ void History::changeMsgId(MsgId oldId, MsgId newId) {
void History::removeBlock(HistoryBlock *block) {
setPendingResize();

t_assert(block->items.isEmpty());

int index = block->indexInHistory();
blocks.removeAt(index);
for (int i = index, l = blocks.size(); i < l; ++i) {
Expand Down Expand Up @@ -2614,7 +2617,7 @@ void HistoryBlock::clear(bool leaveItems) {
void HistoryBlock::removeItem(HistoryItem *item) {
t_assert(item->block() == this);

int32 itemIndex = item->indexInBlock();
int itemIndex = item->indexInBlock();
if (history->showFrom == item) {
history->getNextShowFrom(this, itemIndex);
}
Expand All @@ -2625,13 +2628,14 @@ void HistoryBlock::removeItem(HistoryItem *item) {
history->getNextScrollTopItem(this, itemIndex);
}

int myIndex = indexInHistory();
if (myIndex >= 0) { // fix message groups
int blockIndex = indexInHistory();
if (blockIndex >= 0) { // fix message groups
if (item->isImportant()) { // unite message groups around this important message
HistoryGroup *nextGroup = 0, *prevGroup = 0;
HistoryCollapse *nextCollapse = 0;
HistoryItem *prevItem = 0;
for (int32 nextBlock = myIndex, nextIndex = qMin(items.size(), itemIndex + 1); nextBlock < history->blocks.size(); ++nextBlock) {
HistoryGroup *nextGroup = nullptr;
HistoryGroup *prevGroup = nullptr;
HistoryCollapse *nextCollapse = nullptr;
HistoryItem *prevItem = nullptr;
for (int nextBlock = blockIndex, nextIndex = qMin(items.size(), itemIndex + 1); nextBlock < history->blocks.size(); ++nextBlock) {
HistoryBlock *block = history->blocks.at(nextBlock);
for (; nextIndex < block->items.size(); ++nextIndex) {
HistoryItem *item = block->items.at(nextIndex);
Expand All @@ -2651,7 +2655,7 @@ void HistoryBlock::removeItem(HistoryItem *item) {
break;
}
}
for (int32 prevBlock = myIndex + 1, prevIndex = qMax(1, itemIndex); prevBlock > 0;) {
for (int prevBlock = blockIndex + 1, prevIndex = qMax(1, itemIndex); prevBlock > 0;) {
--prevBlock;
HistoryBlock *block = history->blocks.at(prevBlock);
if (!prevIndex) prevIndex = block->items.size();
Expand Down Expand Up @@ -2680,7 +2684,9 @@ void HistoryBlock::removeItem(HistoryItem *item) {
}
}
}
// myIndex can be invalid now, because of destroying previous blocks
// blockIndex can be invalid now, because of destroying previous blocks
blockIndex = indexInHistory();
itemIndex = item->indexInBlock();

items.remove(itemIndex);
for (int i = itemIndex, l = items.size(); i < l; ++i) {
Expand Down

0 comments on commit 3132e4d

Please sign in to comment.