version 9034001 beta

This commit is contained in:
John Preston 2016-03-22 18:23:34 +03:00
parent f662067a68
commit 5c9836418f
10 changed files with 124 additions and 117 deletions

View File

@ -1049,7 +1049,7 @@ msgServiceNameFont: semiboldFont;
msgServicePhotoWidth: 100px; msgServicePhotoWidth: 100px;
msgDateFont: font(13px); msgDateFont: font(13px);
msgMinWidth: 190px; msgMinWidth: 190px;
msgPhotoSize: 35px; msgPhotoSize: 33px;
msgPhotoSkip: 40px; msgPhotoSkip: 40px;
msgPadding: margins(13px, 7px, 13px, 8px); msgPadding: margins(13px, 7px, 13px, 8px);
msgMargin: margins(13px, 6px, 53px, 2px); msgMargin: margins(13px, 6px, 53px, 2px);
@ -1089,7 +1089,7 @@ msgServiceBg: #89a0b47f;
msgServiceSelectBg: #bbc8d4a2; msgServiceSelectBg: #bbc8d4a2;
msgServiceColor: #FFF; msgServiceColor: #FFF;
msgServicePadding: margins(12px, 3px, 12px, 4px); msgServicePadding: margins(12px, 3px, 12px, 4px);
msgServiceMargin: margins(10px, 7px, 80px, 7px); msgServiceMargin: margins(10px, 9px, 80px, 5px);
msgColor: #000; msgColor: #000;
msgDateColor: #000; msgDateColor: #000;

View File

@ -145,10 +145,11 @@ namespace App {
History *historyLoaded(const PeerId &peer); History *historyLoaded(const PeerId &peer);
HistoryItem *histItemById(ChannelId channelId, MsgId itemId); HistoryItem *histItemById(ChannelId channelId, MsgId itemId);
inline History *history(const PeerData *peer) { inline History *history(const PeerData *peer) {
t_assert(peer != nullptr);
return history(peer->id); return history(peer->id);
} }
inline History *historyLoaded(const PeerData *peer) { inline History *historyLoaded(const PeerData *peer) {
return historyLoaded(peer->id); return peer ? historyLoaded(peer->id) : nullptr;
} }
inline HistoryItem *histItemById(const ChannelData *channel, MsgId itemId) { inline HistoryItem *histItemById(const ChannelData *channel, MsgId itemId) {
return histItemById(channel ? peerToChannel(channel->id) : 0, itemId); return histItemById(channel ? peerToChannel(channel->id) : 0, itemId);

View File

@ -22,8 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
static const int32 AppVersion = 9034; static const int32 AppVersion = 9034;
static const wchar_t *AppVersionStr = L"0.9.34"; static const wchar_t *AppVersionStr = L"0.9.34";
static const bool DevVersion = true; static const bool DevVersion = false;
//#define BETA_VERSION (9030002ULL) // just comment this line to build public version #define BETA_VERSION (9034001ULL) // just comment this line to build public version
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";
static const wchar_t *AppName = L"Telegram Desktop"; static const wchar_t *AppName = L"Telegram Desktop";

View File

@ -489,7 +489,7 @@ void ChannelHistory::insertCollapseItem(MsgId wasMinId) {
if (_onlyImportant || isMegagroup()) return; if (_onlyImportant || isMegagroup()) return;
bool insertAfter = false; bool insertAfter = false;
for (int32 blockIndex = 1, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) { // skip first date block for (int32 blockIndex = 0, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) {
HistoryBlock *block = blocks.at(blockIndex); HistoryBlock *block = blocks.at(blockIndex);
for (int32 itemIndex = 0, itemsCount = block->items.size(); itemIndex < itemsCount; ++itemIndex) { for (int32 itemIndex = 0, itemsCount = block->items.size(); itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex); HistoryItem *item = block->items.at(itemIndex);
@ -572,7 +572,7 @@ void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
if (onlyImportant()) { if (onlyImportant()) {
if (newLoaded) { if (newLoaded) {
HistoryBlock *block = blocks.isEmpty() ? addNewLastBlock() : blocks.back(); HistoryBlock *block = blocks.isEmpty() ? pushBackNewBlock() : blocks.back();
HistoryItem *prev = block->items.isEmpty() ? nullptr : block->items.back(); HistoryItem *prev = block->items.isEmpty() ? nullptr : block->items.back();
prev = addMessageGroupAfterPrevToBlock(d, prev, block); prev = addMessageGroupAfterPrevToBlock(d, prev, block);
@ -609,7 +609,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
return _joinedMessage; return _joinedMessage;
} }
for (int32 blockIndex = blocks.size(); blockIndex > 1;) { for (int32 blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex); HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) { for (int32 itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex); HistoryItem *item = block->items.at(--itemIndex);
@ -637,10 +637,10 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
} }
// adding new item to new block // adding new item to new block
HistoryBlock *block = addNewFirstBlock(); HistoryBlock *block = pushFrontNewBlock();
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags); _joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
addItemAfterPrevToBlock(_joinedMessage, nullptr, block); addItemToBlock(_joinedMessage, block);
t_assert(blocks.size() > 1); t_assert(blocks.size() > 1);
blocks.at(1)->items.front()->previousItemChanged(); blocks.at(1)->items.front()->previousItemChanged();
@ -665,9 +665,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
QDateTime inviteDate = peer->asChannel()->inviteDate; QDateTime inviteDate = peer->asChannel()->inviteDate;
QDateTime firstDate, lastDate; QDateTime firstDate, lastDate;
for (int32 blockIndex = 1, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) { for (int blockIndex = 0, blocksCount = blocks.size(); blockIndex < blocksCount; ++blockIndex) {
HistoryBlock *block = blocks.at(blockIndex); HistoryBlock *block = blocks.at(blockIndex);
int32 itemIndex = 0, itemsCount = block->items.size(); int itemIndex = 0, itemsCount = block->items.size();
for (; itemIndex < itemsCount; ++itemIndex) { for (; itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex); HistoryItem *item = block->items.at(itemIndex);
HistoryItemType type = item->type(); HistoryItemType type = item->type();
@ -678,9 +678,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
} }
if (itemIndex < itemsCount) break; if (itemIndex < itemsCount) break;
} }
for (int32 blockIndex = blocks.size(); blockIndex > 1;) { for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex); HistoryBlock *block = blocks.at(--blockIndex);
int32 itemIndex = block->items.size(); int itemIndex = block->items.size();
for (; itemIndex > 0;) { for (; itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex); HistoryItem *item = block->items.at(--itemIndex);
HistoryItemType type = item->type(); HistoryItemType type = item->type();
@ -706,9 +706,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
void ChannelHistory::checkMaxReadMessageDate() { void ChannelHistory::checkMaxReadMessageDate() {
if (_maxReadMessageDate.isValid()) return; if (_maxReadMessageDate.isValid()) return;
for (int32 blockIndex = blocks.size(); blockIndex > 0;) { for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex); HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) { for (int itemIndex = block->items.size(); itemIndex > 0;) {
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;
@ -753,8 +753,15 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
if (!isImportant && onlyImportant()) { if (!isImportant && onlyImportant()) {
HistoryItem *item = addToHistory(msg), *prev = isEmpty() ? nullptr : blocks.back()->items.back(); HistoryItem *item = addToHistory(msg), *prev = isEmpty() ? nullptr : blocks.back()->items.back();
addMessageGroupAfterPrev(item, prev);
return item; if (prev && prev->type() == HistoryItemGroup) {
static_cast<HistoryGroup*>(prev)->uniteWith(item);
return prev;
}
QDateTime date = prev ? prev->date : item->date;
HistoryBlock *block = prev ? prev->block() : pushBackNewBlock();
return addItemToBlock(HistoryGroup::create(this, item, date), block);
} }
// when we are receiving channel dialog rows we get one important and one not important // when we are receiving channel dialog rows we get one important and one not important
@ -795,7 +802,7 @@ void ChannelHistory::switchMode() {
OtherList savedList; OtherList savedList;
if (!blocks.isEmpty()) { if (!blocks.isEmpty()) {
savedList.reserve(((blocks.size() - 2) * MessagesPerPage + blocks.back()->items.size()) * (onlyImportant() ? 2 : 1)); savedList.reserve(((blocks.size() - 1) * MessagesPerPage + blocks.back()->items.size()) * (onlyImportant() ? 2 : 1));
for_const (const HistoryBlock *block, blocks) { for_const (const HistoryBlock *block, blocks) {
for_const (HistoryItem *item, block->items) { for_const (HistoryItem *item, block->items) {
HistoryItemType itemType = item->type(); HistoryItemType itemType = item->type();
@ -811,17 +818,16 @@ void ChannelHistory::switchMode() {
newLoaded = _otherNewLoaded; newLoaded = _otherNewLoaded;
oldLoaded = _otherOldLoaded; oldLoaded = _otherOldLoaded;
if (int32 count = _otherList.size()) { if (int count = _otherList.size()) {
blocks.reserve(qCeil(count / float64(MessagesPerPage)) + 1); blocks.reserve(qCeil(count / float64(MessagesPerPage)));
HistoryItem *prev = 0; for (int i = 0; i < count;) {
for (int32 i = 0; i < count;) { HistoryBlock *block = pushBackNewBlock();
HistoryBlock *block = addNewLastBlock();
int32 willAddToBlock = qMin(int32(MessagesPerPage), count - i); int willAddToBlock = qMin(int(MessagesPerPage), count - i);
block->items.reserve(willAddToBlock); block->items.reserve(willAddToBlock);
for (int32 till = i + willAddToBlock; i < till; ++i) { for (int till = i + willAddToBlock; i < till; ++i) {
prev = addItemAfterPrevToBlock(_otherList.at(i), prev, block); addItemToBlock(_otherList.at(i), block);
} }
t_assert(!block->items.isEmpty()); t_assert(!block->items.isEmpty());
@ -883,11 +889,11 @@ HistoryGroup *ChannelHistory::findGroup(MsgId msgId) const { // find message gro
} }
HistoryBlock *ChannelHistory::findGroupBlock(MsgId msgId) const { // find block with message group using binary search HistoryBlock *ChannelHistory::findGroupBlock(MsgId msgId) const { // find block with message group using binary search
if (isEmpty()) return 0; if (isEmpty()) return nullptr;
int32 blockIndex = 0; int blockIndex = 0;
if (blocks.size() > 1) for (int32 minBlock = 0, maxBlock = blocks.size();;) { if (blocks.size() > 1) for (int minBlock = 0, maxBlock = blocks.size();;) {
for (int32 startCheckBlock = (minBlock + maxBlock) / 2, checkBlock = startCheckBlock;;) { for (int startCheckBlock = (minBlock + maxBlock) / 2, checkBlock = startCheckBlock;;) {
HistoryBlock *block = blocks.at(checkBlock); HistoryBlock *block = blocks.at(checkBlock);
auto i = block->items.cbegin(), e = block->items.cend(); auto i = block->items.cbegin(), e = block->items.cend();
for (; i != e; ++i) { // out msgs could be a mess in monotonic ids for (; i != e; ++i) { // out msgs could be a mess in monotonic ids
@ -952,8 +958,8 @@ HistoryGroup *ChannelHistory::findGroupInOther(MsgId msgId) const { // find mess
HistoryItem *ChannelHistory::findPrevItem(HistoryItem *item) const { HistoryItem *ChannelHistory::findPrevItem(HistoryItem *item) const {
if (item->detached()) return nullptr; if (item->detached()) return nullptr;
int32 itemIndex = item->indexInBlock(); int itemIndex = item->indexInBlock();
int32 blockIndex = item->block()->indexInHistory(); int blockIndex = item->block()->indexInHistory();
for (++blockIndex, ++itemIndex; blockIndex > 0;) { for (++blockIndex, ++itemIndex; blockIndex > 0;) {
--blockIndex; --blockIndex;
HistoryBlock *block = blocks.at(blockIndex); HistoryBlock *block = blocks.at(blockIndex);
@ -1547,7 +1553,7 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) {
t_assert(adding != nullptr); t_assert(adding != nullptr);
t_assert(adding->detached()); t_assert(adding->detached());
HistoryBlock *block = blocks.isEmpty() ? addNewLastBlock() : blocks.back(); HistoryBlock *block = blocks.isEmpty() ? pushBackNewBlock() : blocks.back();
adding->attachToBlock(block, block->items.size()); adding->attachToBlock(block, block->items.size());
block->items.push_back(adding); block->items.push_back(adding);
@ -1665,7 +1671,7 @@ void History::newItemAdded(HistoryItem *item) {
} }
} }
HistoryItem *History::addItemAfterPrevToBlock(HistoryItem *item, HistoryItem *prev, HistoryBlock *block) { HistoryItem *History::addItemToBlock(HistoryItem *item, HistoryBlock *block) {
item->attachToBlock(block, block->items.size()); item->attachToBlock(block, block->items.size());
block->items.push_back(item); block->items.push_back(item);
item->previousItemChanged(); item->previousItemChanged();
@ -1677,22 +1683,7 @@ HistoryItem *History::addMessageGroupAfterPrevToBlock(const MTPDmessageGroup &gr
static_cast<HistoryGroup*>(prev)->uniteWith(group.vmin_id.v, group.vmax_id.v, group.vcount.v); static_cast<HistoryGroup*>(prev)->uniteWith(group.vmin_id.v, group.vmax_id.v, group.vcount.v);
return prev; return prev;
} }
return addItemAfterPrevToBlock(HistoryGroup::create(this, group, prev ? prev->date : date(group.vdate)), prev, block); return addItemToBlock(HistoryGroup::create(this, group, prev ? prev->date : date(group.vdate)), block);
}
HistoryItem *History::addMessageGroupAfterPrev(HistoryItem *newItem, HistoryItem *prev) {
if (prev && prev->type() == HistoryItemGroup) {
static_cast<HistoryGroup*>(prev)->uniteWith(newItem);
return prev;
}
QDateTime date = prev ? prev->date : newItem->date;
HistoryBlock *block = prev ? prev->block() : 0;
if (!block) {
block = new HistoryBlock(this);
blocks.push_back(block);
}
return addItemAfterPrevToBlock(HistoryGroup::create(this, newItem, date), prev, block);
} }
void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPMessageGroup> *collapsed) { void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPMessageGroup> *collapsed) {
@ -1710,7 +1701,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0; const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0;
HistoryItem *prev = nullptr; HistoryItem *prev = nullptr;
HistoryBlock *block = addNewFirstBlock(); HistoryBlock *block = pushFrontNewBlock();
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0)); block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
for (auto i = slice.cend(), e = slice.cbegin(); i != e;) { for (auto i = slice.cend(), e = slice.cbegin(); i != e;) {
@ -1726,7 +1717,7 @@ void History::addOlderSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
prev = addMessageGroupAfterPrevToBlock(group, prev, block); prev = addMessageGroupAfterPrevToBlock(group, prev, block);
} }
prev = addItemAfterPrevToBlock(adding, prev, block); prev = addItemToBlock(adding, block);
} }
for (; groupsIt != groupsEnd; ++groupsIt) { for (; groupsIt != groupsEnd; ++groupsIt) {
if (groupsIt->type() != mtpc_messageGroup) continue; if (groupsIt->type() != mtpc_messageGroup) continue;
@ -1859,7 +1850,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
HistoryItem *prev = blocks.isEmpty() ? nullptr : blocks.back()->items.back(); HistoryItem *prev = blocks.isEmpty() ? nullptr : blocks.back()->items.back();
HistoryBlock *block = addNewLastBlock(); HistoryBlock *block = pushBackNewBlock();
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0)); block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
for (auto i = slice.cend(), e = slice.cbegin(); i != e;) { for (auto i = slice.cend(), e = slice.cbegin(); i != e;) {
@ -1875,7 +1866,7 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
prev = addMessageGroupAfterPrevToBlock(group, prev, block); prev = addMessageGroupAfterPrevToBlock(group, prev, block);
} }
prev = addItemAfterPrevToBlock(adding, prev, block); prev = addItemToBlock(adding, block);
} }
for (; groupsIt != groupsEnd; ++groupsIt) { for (; groupsIt != groupsEnd; ++groupsIt) {
if (groupsIt->type() != mtpc_messageGroup) continue; if (groupsIt->type() != mtpc_messageGroup) continue;
@ -1904,11 +1895,9 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
mask |= (1 << i); mask |= (1 << i);
} }
} }
bool channel = isChannel(); for_const (HistoryBlock *block, blocks) {
for (int32 i = 0; i < blocks.size(); ++i) { for_const (HistoryItem *item, block->items) {
HistoryBlock *b = blocks[i]; mask |= item->addToOverview(AddToOverviewBack);
for (int32 j = 0; j < b->items.size(); ++j) {
mask |= b->items[j]->addToOverview(AddToOverviewBack);
} }
} }
for (int32 t = 0; t < OverviewCount; ++t) { for (int32 t = 0; t < OverviewCount; ++t) {
@ -1919,8 +1908,8 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
if (isChannel()) asChannelHistory()->checkJoinedMessage(); if (isChannel()) asChannelHistory()->checkJoinedMessage();
} }
int32 History::countUnread(MsgId upTo) { int History::countUnread(MsgId upTo) {
int32 result = 0; int result = 0;
for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) { for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {
--i; --i;
for (auto j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) { for (auto j = (*i)->items.cend(), en = (*i)->items.cbegin(); j != en;) {
@ -1994,21 +1983,23 @@ MsgId History::outboxRead(HistoryItem *wasRead) {
} }
HistoryItem *History::lastImportantMessage() const { HistoryItem *History::lastImportantMessage() const {
if (isEmpty()) return 0; if (isEmpty()) {
bool channel = isChannel(); return nullptr;
for (int32 blockIndex = blocks.size(); blockIndex > 0;) { }
bool importantOnly = isChannel() && !isMegagroup();
for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex); HistoryBlock *block = blocks.at(--blockIndex);
for (int32 itemIndex = block->items.size(); itemIndex > 0;) { for (int itemIndex = block->items.size(); itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex); HistoryItem *item = block->items.at(--itemIndex);
if ((channel && !isMegagroup()) ? item->isImportant() : (item->type() == HistoryItemMsg)) { if (importantOnly ? item->isImportant() : (item->type() == HistoryItemMsg)) {
return item; return item;
} }
} }
} }
return 0; return nullptr;
} }
void History::setUnreadCount(int32 newUnreadCount, bool psUpdate) { void History::setUnreadCount(int newUnreadCount, bool psUpdate) {
if (unreadCount != newUnreadCount) { if (unreadCount != newUnreadCount) {
if (newUnreadCount == 1) { if (newUnreadCount == 1) {
if (loadedAtBottom()) showFrom = lastImportantMessage(); if (loadedAtBottom()) showFrom = lastImportantMessage();
@ -2051,9 +2042,9 @@ void History::setUnreadCount(int32 newUnreadCount, bool psUpdate) {
} }
} }
void History::getNextShowFrom(HistoryBlock *block, int32 i) { void History::getNextShowFrom(HistoryBlock *block, int i) {
if (i >= 0) { if (i >= 0) {
int32 l = block->items.size(); int l = block->items.size();
for (++i; i < l; ++i) { for (++i; i < l; ++i) {
if (block->items.at(i)->type() == HistoryItemMsg) { if (block->items.at(i)->type() == HistoryItemMsg) {
showFrom = block->items.at(i); showFrom = block->items.at(i);
@ -2062,7 +2053,7 @@ void History::getNextShowFrom(HistoryBlock *block, int32 i) {
} }
} }
for (int32 j = block->indexInHistory() + 1, s = blocks.size(); j < s; ++j) { for (int j = block->indexInHistory() + 1, s = blocks.size(); j < s; ++j) {
block = blocks.at(j); block = blocks.at(j);
for_const (HistoryItem *item, block->items) { for_const (HistoryItem *item, block->items) {
if (item->type() == HistoryItemMsg) { if (item->type() == HistoryItemMsg) {
@ -2190,14 +2181,14 @@ HistoryItem *History::addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex,
return newItem; return newItem;
} }
HistoryBlock *History::addNewLastBlock() { HistoryBlock *History::pushBackNewBlock() {
HistoryBlock *result = new HistoryBlock(this); HistoryBlock *result = new HistoryBlock(this);
result->setIndexInHistory(blocks.size()); result->setIndexInHistory(blocks.size());
blocks.push_back(result); blocks.push_back(result);
return result; return result;
} }
HistoryBlock *History::addNewFirstBlock() { HistoryBlock *History::pushFrontNewBlock() {
HistoryBlock *result = new HistoryBlock(this); HistoryBlock *result = new HistoryBlock(this);
result->setIndexInHistory(0); result->setIndexInHistory(0);
blocks.push_front(result); blocks.push_front(result);
@ -2641,8 +2632,8 @@ void HistoryBlock::removeItem(HistoryItem *item) {
history->getNextScrollTopItem(this, itemIndex); history->getNextScrollTopItem(this, itemIndex);
} }
int32 myIndex = history->blocks.indexOf(this); int myIndex = indexInHistory();
if (myIndex >= 0) { // fix message groups and date items if (myIndex >= 0) { // fix message groups
if (item->isImportant()) { // unite message groups around this important message if (item->isImportant()) { // unite message groups around this important message
HistoryGroup *nextGroup = 0, *prevGroup = 0; HistoryGroup *nextGroup = 0, *prevGroup = 0;
HistoryCollapse *nextCollapse = 0; HistoryCollapse *nextCollapse = 0;
@ -6588,7 +6579,6 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
unreadbar->paint(p, 0, _history->width); unreadbar->paint(p, 0, _history->width);
p.translate(0, -dateh); p.translate(0, -dateh);
} }
int skiph = dateh + unreadbarh;
uint64 animms = App::main() ? App::main()->animActiveTimeStart(this) : 0; uint64 animms = App::main() ? App::main()->animActiveTimeStart(this) : 0;
if (animms > 0 && animms <= ms) { if (animms > 0 && animms <= ms) {
@ -6596,6 +6586,8 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) { if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) {
App::main()->stopAnimActive(); App::main()->stopAnimActive();
} else { } else {
int skiph = marginTop() - marginBottom();
float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration)); float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration));
float64 o = p.opacity(); float64 o = p.opacity();
p.setOpacity(o * dt); p.setOpacity(o * dt);
@ -7651,11 +7643,13 @@ void HistoryServiceMessage::draw(Painter &p, const QRect &r, uint32 selection, u
if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) { if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) {
App::main()->stopAnimActive(); App::main()->stopAnimActive();
} else { } else {
int skiph = st::msgServiceMargin.top() - st::msgServiceMargin.bottom();
textstyleSet(&st::inTextStyle); textstyleSet(&st::inTextStyle);
float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration)); float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration));
float64 o = p.opacity(); float64 o = p.opacity();
p.setOpacity(o * dt); p.setOpacity(o * dt);
p.fillRect(0, 0, _history->width, _height, textstyleCurrent()->selectOverlay->b); p.fillRect(0, skiph, _history->width, _height - skiph, textstyleCurrent()->selectOverlay->b);
p.setOpacity(o); p.setOpacity(o);
} }
} }

View File

@ -258,7 +258,7 @@ public:
void newItemAdded(HistoryItem *item); void newItemAdded(HistoryItem *item);
void unregTyping(UserData *from); void unregTyping(UserData *from);
int32 countUnread(MsgId upTo); int countUnread(MsgId upTo);
void updateShowFrom(); void updateShowFrom();
MsgId inboxRead(MsgId upTo); MsgId inboxRead(MsgId upTo);
MsgId inboxRead(HistoryItem *wasRead); MsgId inboxRead(HistoryItem *wasRead);
@ -267,9 +267,9 @@ public:
HistoryItem *lastImportantMessage() const; HistoryItem *lastImportantMessage() const;
void setUnreadCount(int32 newUnreadCount, bool psUpdate = true); void setUnreadCount(int newUnreadCount, bool psUpdate = true);
void setMute(bool newMute); void setMute(bool newMute);
void getNextShowFrom(HistoryBlock *block, int32 i); void getNextShowFrom(HistoryBlock *block, int i);
void addUnreadBar(); void addUnreadBar();
void destroyUnreadBar(); void destroyUnreadBar();
void clearNotifications(); void clearNotifications();
@ -500,14 +500,13 @@ private:
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);
HistoryItem *createItemPhoto(MsgId id, MTPDmessage::Flags flags, int32 viaBotId, MsgId replyTo, QDateTime date, int32 from, PhotoData *photo, const QString &caption); HistoryItem *createItemPhoto(MsgId id, MTPDmessage::Flags flags, int32 viaBotId, MsgId replyTo, QDateTime date, int32 from, PhotoData *photo, const QString &caption);
HistoryItem *addItemAfterPrevToBlock(HistoryItem *item, HistoryItem *prev, HistoryBlock *block); HistoryItem *addItemToBlock(HistoryItem *item, HistoryBlock *block);
HistoryItem *addNewItem(HistoryItem *adding, bool newMsg); HistoryItem *addNewItem(HistoryItem *adding, bool newMsg);
HistoryItem *addMessageGroupAfterPrevToBlock(const MTPDmessageGroup &group, HistoryItem *prev, HistoryBlock *block); HistoryItem *addMessageGroupAfterPrevToBlock(const MTPDmessageGroup &group, HistoryItem *prev, HistoryBlock *block);
HistoryItem *addMessageGroupAfterPrev(HistoryItem *newItem, HistoryItem *prev);
HistoryItem *addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex, int32 itemIndex); HistoryItem *addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex, int32 itemIndex);
HistoryBlock *addNewLastBlock(); HistoryBlock *pushBackNewBlock();
HistoryBlock *addNewFirstBlock(); HistoryBlock *pushFrontNewBlock();
}; };

View File

@ -1359,6 +1359,8 @@ HistoryItem *HistoryInner::atTopImportantMsg(int32 top, int32 height, int32 &bot
} }
void HistoryInner::visibleAreaUpdated(int top, int bottom) { void HistoryInner::visibleAreaUpdated(int top, int bottom) {
_visibleAreaTop = top;
// if history has pending resize events we should not update scrollTopItem // if history has pending resize events we should not update scrollTopItem
if (_history->hasPendingResizedItems()) { if (_history->hasPendingResizedItems()) {
return; return;
@ -1469,59 +1471,59 @@ void HistoryInner::adjustCurrent(int32 y, History *history) const {
_curBlock = history->blocks.size() - 1; _curBlock = history->blocks.size() - 1;
_curItem = 0; _curItem = 0;
} }
while (history->blocks[_curBlock]->y > y && _curBlock > 0) { while (history->blocks.at(_curBlock)->y > y && _curBlock > 0) {
--_curBlock; --_curBlock;
_curItem = 0; _curItem = 0;
} }
while (history->blocks[_curBlock]->y + history->blocks[_curBlock]->height <= y && _curBlock + 1 < history->blocks.size()) { while (history->blocks.at(_curBlock)->y + history->blocks.at(_curBlock)->height <= y && _curBlock + 1 < history->blocks.size()) {
++_curBlock; ++_curBlock;
_curItem = 0; _curItem = 0;
} }
HistoryBlock *block = history->blocks[_curBlock]; HistoryBlock *block = history->blocks.at(_curBlock);
if (_curItem >= block->items.size()) { if (_curItem >= block->items.size()) {
_curItem = block->items.size() - 1; _curItem = block->items.size() - 1;
} }
int32 by = block->y; int by = block->y;
while (block->items[_curItem]->y + by > y && _curItem > 0) { while (block->items.at(_curItem)->y + by > y && _curItem > 0) {
--_curItem; --_curItem;
} }
while (block->items[_curItem]->y + block->items[_curItem]->height() + by <= y && _curItem + 1 < block->items.size()) { while (block->items.at(_curItem)->y + block->items.at(_curItem)->height() + by <= y && _curItem + 1 < block->items.size()) {
++_curItem; ++_curItem;
} }
} }
HistoryItem *HistoryInner::prevItem(HistoryItem *item) { HistoryItem *HistoryInner::prevItem(HistoryItem *item) {
if (!item) return 0; if (!item || item->detached()) return nullptr;
HistoryBlock *block = item->block(); HistoryBlock *block = item->block();
int32 blockIndex = item->history()->blocks.indexOf(block), itemIndex = block->items.indexOf(item); int blockIndex = block->indexInHistory(), itemIndex = item->indexInBlock();
if (blockIndex < 0 || itemIndex < 0) return 0;
if (itemIndex > 0) { if (itemIndex > 0) {
return block->items[itemIndex - 1]; return block->items.at(itemIndex - 1);
} }
if (blockIndex > 0) { if (blockIndex > 0) {
return item->history()->blocks[blockIndex - 1]->items.back(); return item->history()->blocks.at(blockIndex - 1)->items.back();
} }
if (item->history() == _history && _migrated && _history->loadedAtTop() && !_migrated->isEmpty() && _migrated->loadedAtBottom()) { if (item->history() == _history && _migrated && _history->loadedAtTop() && !_migrated->isEmpty() && _migrated->loadedAtBottom()) {
return _migrated->blocks.back()->items.back(); return _migrated->blocks.back()->items.back();
} }
return 0; return nullptr;
} }
HistoryItem *HistoryInner::nextItem(HistoryItem *item) { HistoryItem *HistoryInner::nextItem(HistoryItem *item) {
if (!item) return 0; if (!item || item->detached()) return nullptr;
HistoryBlock *block = item->block(); HistoryBlock *block = item->block();
int32 blockIndex = item->history()->blocks.indexOf(block), itemIndex = block->items.indexOf(item); int blockIndex = block->indexInHistory(), itemIndex = item->indexInBlock();
if (blockIndex < 0 || itemIndex < 0) return 0;
if (itemIndex + 1 < block->items.size()) { if (itemIndex + 1 < block->items.size()) {
return block->items[itemIndex + 1]; return block->items.at(itemIndex + 1);
} }
if (blockIndex + 1 < item->history()->blocks.size()) { if (blockIndex + 1 < item->history()->blocks.size()) {
return item->history()->blocks[blockIndex + 1]->items.front(); return item->history()->blocks.at(blockIndex + 1)->items.front();
} }
if (item->history() == _migrated && _history && _migrated->loadedAtBottom() && _history->loadedAtTop() && !_history->isEmpty()) { if (item->history() == _migrated && _history && _migrated->loadedAtBottom() && _history->loadedAtTop() && !_history->isEmpty()) {
return _history->blocks.front()->items.front(); return _history->blocks.front()->items.front();
} }
return 0; return nullptr;
} }
bool HistoryInner::canCopySelected() const { bool HistoryInner::canCopySelected() const {
@ -1877,8 +1879,8 @@ void HistoryInner::applyDragSelection(SelectedItems *toItems) const {
toItems->clear(); toItems->clear();
} }
if (_dragSelecting) { if (_dragSelecting) {
int32 fromblock = _dragSelFrom->history()->blocks.indexOf(_dragSelFrom->block()), fromitem = _dragSelFrom->block()->items.indexOf(_dragSelFrom); int32 fromblock = _dragSelFrom->block()->indexInHistory(), fromitem = _dragSelFrom->indexInBlock();
int32 toblock = _dragSelTo->history()->blocks.indexOf(_dragSelTo->block()), toitem = _dragSelTo->block()->items.indexOf(_dragSelTo); int32 toblock = _dragSelTo->block()->indexInHistory(), toitem = _dragSelTo->indexInBlock();
if (_migrated) { if (_migrated) {
if (_dragSelFrom->history() == _migrated) { if (_dragSelFrom->history() == _migrated) {
if (_dragSelTo->history() == _migrated) { if (_dragSelTo->history() == _migrated) {
@ -3571,6 +3573,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
if (_history) { if (_history) {
if (_peer->id == peerId && !reload) { if (_peer->id == peerId && !reload) {
_history->forgetScrollState(); _history->forgetScrollState();
if (_migrated) {
_migrated->forgetScrollState();
}
bool wasOnlyImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : true; bool wasOnlyImportant = _history->isChannel() ? _history->asChannelHistory()->onlyImportant() : true;
@ -3715,6 +3720,9 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
} }
} else { } else {
_history->forgetScrollState(); _history->forgetScrollState();
if (_migrated) {
_migrated->forgetScrollState();
}
} }
_list = new HistoryInner(this, &_scroll, _history); _list = new HistoryInner(this, &_scroll, _history);
@ -3726,7 +3734,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
_updateHistoryItems.stop(); _updateHistoryItems.stop();
pinnedMsgVisibilityUpdated(); pinnedMsgVisibilityUpdated();
if (_history->scrollTopItem || _history->isReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop)) { if (_history->scrollTopItem || (_migrated && _migrated->scrollTopItem) || _history->isReadyFor(_showAtMsgId, _fixedInScrollMsgId, _fixedInScrollMsgTop)) {
_fixedInScrollMsgId = 0; _fixedInScrollMsgId = 0;
_fixedInScrollMsgTop = 0; _fixedInScrollMsgTop = 0;
historyLoaded(); historyLoaded();
@ -4191,6 +4199,9 @@ void HistoryWidget::newUnreadMsg(History *history, HistoryItem *item) {
void HistoryWidget::historyToDown(History *history) { void HistoryWidget::historyToDown(History *history) {
history->forgetScrollState(); history->forgetScrollState();
if (History *migrated = App::historyLoaded(history->peer->migrateFrom())) {
migrated->forgetScrollState();
}
if (history == _history) { if (history == _history) {
_scroll.scrollToY(_scroll.scrollTopMax()); _scroll.scrollToY(_scroll.scrollTopMax());
} }
@ -6406,7 +6417,7 @@ void HistoryWidget::updateListSize(bool initial, bool loadedDown, const ScrollCh
} }
int32 toY = ScrollMax; int32 toY = ScrollMax;
if (initial && _history->scrollTopItem) { if (initial && (_history->scrollTopItem || (_migrated && _migrated->scrollTopItem))) {
toY = _list->historyScrollTop(); toY = _list->historyScrollTop();
} else if (initial && _migrated && _showAtMsgId < 0 && -_showAtMsgId < ServerMaxMsgId) { } else if (initial && _migrated && _showAtMsgId < 0 && -_showAtMsgId < ServerMaxMsgId) {
HistoryItem *item = App::histItemById(0, -_showAtMsgId); HistoryItem *item = App::histItemById(0, -_showAtMsgId);
@ -7059,8 +7070,8 @@ void HistoryWidget::onReplyToMessage() {
if (!to || to->id <= 0 || !_canSendMessages) return; if (!to || to->id <= 0 || !_canSendMessages) return;
if (to->history() == _migrated) { if (to->history() == _migrated) {
if (to->isGroupMigrate() && _history->blocks.size() > 1 && _history->blocks.at(1)->items.front()->isGroupMigrate() && _history != _migrated) { if (to->isGroupMigrate() && !_history->isEmpty() && _history->blocks.front()->items.front()->isGroupMigrate() && _history != _migrated) {
App::contextItem(_history->blocks.at(1)->items.front()); App::contextItem(_history->blocks.front()->items.front());
onReplyToMessage(); onReplyToMessage();
App::contextItem(to); App::contextItem(to);
} else { } else {

View File

@ -197,6 +197,8 @@ private:
PopupMenu *_menu; PopupMenu *_menu;
int _visibleAreaTop = 0;
}; };
class MessageField : public FlatTextarea { class MessageField : public FlatTextarea {

View File

@ -1682,9 +1682,9 @@ void MainWidget::overviewLoaded(History *history, const MTPmessages_Messages &re
void MainWidget::sendReadRequest(PeerData *peer, MsgId upTo) { void MainWidget::sendReadRequest(PeerData *peer, MsgId upTo) {
if (!MTP::authedId()) return; if (!MTP::authedId()) return;
if (peer->isChannel()) { if (peer->isChannel()) {
// _readRequests.insert(peer, qMakePair(MTP::send(MTPchannels_ReadHistory(peer->asChannel()->inputChannel, MTP_int(upTo)), rpcDone(&MainWidget::channelWasRead, peer), rpcFail(&MainWidget::readRequestFail, peer)), upTo)); _readRequests.insert(peer, qMakePair(MTP::send(MTPchannels_ReadHistory(peer->asChannel()->inputChannel, MTP_int(upTo)), rpcDone(&MainWidget::channelWasRead, peer), rpcFail(&MainWidget::readRequestFail, peer)), upTo));
} else { } else {
// _readRequests.insert(peer, qMakePair(MTP::send(MTPmessages_ReadHistory(peer->input, MTP_int(upTo)), rpcDone(&MainWidget::historyWasRead, peer), rpcFail(&MainWidget::readRequestFail, peer)), upTo)); _readRequests.insert(peer, qMakePair(MTP::send(MTPmessages_ReadHistory(peer->input, MTP_int(upTo)), rpcDone(&MainWidget::historyWasRead, peer), rpcFail(&MainWidget::readRequestFail, peer)), upTo));
} }
} }

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "SourceFiles\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,34,0 FILEVERSION 0,9,34,1
PRODUCTVERSION 0,9,34,0 PRODUCTVERSION 0,9,34,1
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.9.34.0" VALUE "FileVersion", "0.9.34.1"
VALUE "LegalCopyright", "Copyright (C) 2014-2016" VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.9.34.0" VALUE "ProductVersion", "0.9.34.1"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -2,5 +2,5 @@ AppVersion 9034
AppVersionStrMajor 0.9 AppVersionStrMajor 0.9
AppVersionStrSmall 0.9.34 AppVersionStrSmall 0.9.34
AppVersionStr 0.9.34 AppVersionStr 0.9.34
DevChannel 1 DevChannel 0
BetaVersion 0 9030002 BetaVersion 9034001