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

View File

@ -145,10 +145,11 @@ namespace App {
History *historyLoaded(const PeerId &peer);
HistoryItem *histItemById(ChannelId channelId, MsgId itemId);
inline History *history(const PeerData *peer) {
t_assert(peer != nullptr);
return history(peer->id);
}
inline History *historyLoaded(const PeerData *peer) {
return historyLoaded(peer->id);
return peer ? historyLoaded(peer->id) : nullptr;
}
inline HistoryItem *histItemById(const ChannelData *channel, MsgId 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 wchar_t *AppVersionStr = L"0.9.34";
static const bool DevVersion = true;
//#define BETA_VERSION (9030002ULL) // just comment this line to build public version
static const bool DevVersion = false;
#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 *AppName = L"Telegram Desktop";

View File

@ -489,7 +489,7 @@ void ChannelHistory::insertCollapseItem(MsgId wasMinId) {
if (_onlyImportant || isMegagroup()) return;
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);
for (int32 itemIndex = 0, itemsCount = block->items.size(); itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex);
@ -572,7 +572,7 @@ void ChannelHistory::addNewGroup(const MTPMessageGroup &group) {
if (onlyImportant()) {
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();
prev = addMessageGroupAfterPrevToBlock(d, prev, block);
@ -609,7 +609,7 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
return _joinedMessage;
}
for (int32 blockIndex = blocks.size(); blockIndex > 1;) {
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);
@ -637,10 +637,10 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) {
}
// adding new item to new block
HistoryBlock *block = addNewFirstBlock();
HistoryBlock *block = pushFrontNewBlock();
_joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags);
addItemAfterPrevToBlock(_joinedMessage, nullptr, block);
addItemToBlock(_joinedMessage, block);
t_assert(blocks.size() > 1);
blocks.at(1)->items.front()->previousItemChanged();
@ -665,9 +665,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
QDateTime inviteDate = peer->asChannel()->inviteDate;
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);
int32 itemIndex = 0, itemsCount = block->items.size();
int itemIndex = 0, itemsCount = block->items.size();
for (; itemIndex < itemsCount; ++itemIndex) {
HistoryItem *item = block->items.at(itemIndex);
HistoryItemType type = item->type();
@ -678,9 +678,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
}
if (itemIndex < itemsCount) break;
}
for (int32 blockIndex = blocks.size(); blockIndex > 1;) {
for (int blockIndex = blocks.size(); blockIndex > 0;) {
HistoryBlock *block = blocks.at(--blockIndex);
int32 itemIndex = block->items.size();
int itemIndex = block->items.size();
for (; itemIndex > 0;) {
HistoryItem *item = block->items.at(--itemIndex);
HistoryItemType type = item->type();
@ -706,9 +706,9 @@ void ChannelHistory::checkJoinedMessage(bool createUnread) {
void ChannelHistory::checkMaxReadMessageDate() {
if (_maxReadMessageDate.isValid()) return;
for (int32 blockIndex = blocks.size(); blockIndex > 0;) {
for (int blockIndex = blocks.size(); blockIndex > 0;) {
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);
if ((item->isImportant() || isMegagroup()) && !item->unread()) {
_maxReadMessageDate = item->date;
@ -753,8 +753,15 @@ HistoryItem *ChannelHistory::addNewToBlocks(const MTPMessage &msg, NewMessageTyp
if (!isImportant && onlyImportant()) {
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
@ -795,7 +802,7 @@ void ChannelHistory::switchMode() {
OtherList savedList;
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 (HistoryItem *item, block->items) {
HistoryItemType itemType = item->type();
@ -811,17 +818,16 @@ void ChannelHistory::switchMode() {
newLoaded = _otherNewLoaded;
oldLoaded = _otherOldLoaded;
if (int32 count = _otherList.size()) {
blocks.reserve(qCeil(count / float64(MessagesPerPage)) + 1);
if (int count = _otherList.size()) {
blocks.reserve(qCeil(count / float64(MessagesPerPage)));
HistoryItem *prev = 0;
for (int32 i = 0; i < count;) {
HistoryBlock *block = addNewLastBlock();
for (int i = 0; i < count;) {
HistoryBlock *block = pushBackNewBlock();
int32 willAddToBlock = qMin(int32(MessagesPerPage), count - i);
int willAddToBlock = qMin(int(MessagesPerPage), count - i);
block->items.reserve(willAddToBlock);
for (int32 till = i + willAddToBlock; i < till; ++i) {
prev = addItemAfterPrevToBlock(_otherList.at(i), prev, block);
for (int till = i + willAddToBlock; i < till; ++i) {
addItemToBlock(_otherList.at(i), block);
}
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
if (isEmpty()) return 0;
if (isEmpty()) return nullptr;
int32 blockIndex = 0;
if (blocks.size() > 1) for (int32 minBlock = 0, maxBlock = blocks.size();;) {
for (int32 startCheckBlock = (minBlock + maxBlock) / 2, checkBlock = startCheckBlock;;) {
int blockIndex = 0;
if (blocks.size() > 1) for (int minBlock = 0, maxBlock = blocks.size();;) {
for (int startCheckBlock = (minBlock + maxBlock) / 2, checkBlock = startCheckBlock;;) {
HistoryBlock *block = blocks.at(checkBlock);
auto i = block->items.cbegin(), e = block->items.cend();
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 {
if (item->detached()) return nullptr;
int32 itemIndex = item->indexInBlock();
int32 blockIndex = item->block()->indexInHistory();
int itemIndex = item->indexInBlock();
int blockIndex = item->block()->indexInHistory();
for (++blockIndex, ++itemIndex; blockIndex > 0;) {
--blockIndex;
HistoryBlock *block = blocks.at(blockIndex);
@ -1547,7 +1553,7 @@ HistoryItem *History::addNewItem(HistoryItem *adding, bool newMsg) {
t_assert(adding != nullptr);
t_assert(adding->detached());
HistoryBlock *block = blocks.isEmpty() ? addNewLastBlock() : blocks.back();
HistoryBlock *block = blocks.isEmpty() ? pushBackNewBlock() : blocks.back();
adding->attachToBlock(block, block->items.size());
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());
block->items.push_back(item);
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);
return prev;
}
return addItemAfterPrevToBlock(HistoryGroup::create(this, group, prev ? prev->date : date(group.vdate)), prev, 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);
return addItemToBlock(HistoryGroup::create(this, group, prev ? prev->date : date(group.vdate)), block);
}
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;
HistoryItem *prev = nullptr;
HistoryBlock *block = addNewFirstBlock();
HistoryBlock *block = pushFrontNewBlock();
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
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 = addItemAfterPrevToBlock(adding, prev, block);
prev = addItemToBlock(adding, block);
}
for (; groupsIt != groupsEnd; ++groupsIt) {
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();
HistoryBlock *block = addNewLastBlock();
HistoryBlock *block = pushBackNewBlock();
block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0));
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 = addItemAfterPrevToBlock(adding, prev, block);
prev = addItemToBlock(adding, block);
}
for (; groupsIt != groupsEnd; ++groupsIt) {
if (groupsIt->type() != mtpc_messageGroup) continue;
@ -1904,11 +1895,9 @@ void History::addNewerSlice(const QVector<MTPMessage> &slice, const QVector<MTPM
mask |= (1 << i);
}
}
bool channel = isChannel();
for (int32 i = 0; i < blocks.size(); ++i) {
HistoryBlock *b = blocks[i];
for (int32 j = 0; j < b->items.size(); ++j) {
mask |= b->items[j]->addToOverview(AddToOverviewBack);
for_const (HistoryBlock *block, blocks) {
for_const (HistoryItem *item, block->items) {
mask |= item->addToOverview(AddToOverviewBack);
}
}
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();
}
int32 History::countUnread(MsgId upTo) {
int32 result = 0;
int History::countUnread(MsgId upTo) {
int result = 0;
for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) {
--i;
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 {
if (isEmpty()) return 0;
bool channel = isChannel();
for (int32 blockIndex = blocks.size(); blockIndex > 0;) {
if (isEmpty()) {
return nullptr;
}
bool importantOnly = isChannel() && !isMegagroup();
for (int blockIndex = blocks.size(); blockIndex > 0;) {
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);
if ((channel && !isMegagroup()) ? item->isImportant() : (item->type() == HistoryItemMsg)) {
if (importantOnly ? item->isImportant() : (item->type() == HistoryItemMsg)) {
return item;
}
}
}
return 0;
return nullptr;
}
void History::setUnreadCount(int32 newUnreadCount, bool psUpdate) {
void History::setUnreadCount(int newUnreadCount, bool psUpdate) {
if (unreadCount != newUnreadCount) {
if (newUnreadCount == 1) {
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) {
int32 l = block->items.size();
int l = block->items.size();
for (++i; i < l; ++i) {
if (block->items.at(i)->type() == HistoryItemMsg) {
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);
for_const (HistoryItem *item, block->items) {
if (item->type() == HistoryItemMsg) {
@ -2190,14 +2181,14 @@ HistoryItem *History::addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex,
return newItem;
}
HistoryBlock *History::addNewLastBlock() {
HistoryBlock *History::pushBackNewBlock() {
HistoryBlock *result = new HistoryBlock(this);
result->setIndexInHistory(blocks.size());
blocks.push_back(result);
return result;
}
HistoryBlock *History::addNewFirstBlock() {
HistoryBlock *History::pushFrontNewBlock() {
HistoryBlock *result = new HistoryBlock(this);
result->setIndexInHistory(0);
blocks.push_front(result);
@ -2641,8 +2632,8 @@ void HistoryBlock::removeItem(HistoryItem *item) {
history->getNextScrollTopItem(this, itemIndex);
}
int32 myIndex = history->blocks.indexOf(this);
if (myIndex >= 0) { // fix message groups and date items
int myIndex = indexInHistory();
if (myIndex >= 0) { // fix message groups
if (item->isImportant()) { // unite message groups around this important message
HistoryGroup *nextGroup = 0, *prevGroup = 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);
p.translate(0, -dateh);
}
int skiph = dateh + unreadbarh;
uint64 animms = App::main() ? App::main()->animActiveTimeStart(this) : 0;
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) {
App::main()->stopAnimActive();
} else {
int skiph = marginTop() - marginBottom();
float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration));
float64 o = p.opacity();
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) {
App::main()->stopAnimActive();
} else {
int skiph = st::msgServiceMargin.top() - st::msgServiceMargin.bottom();
textstyleSet(&st::inTextStyle);
float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration));
float64 o = p.opacity();
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);
}
}

View File

@ -258,7 +258,7 @@ public:
void newItemAdded(HistoryItem *item);
void unregTyping(UserData *from);
int32 countUnread(MsgId upTo);
int countUnread(MsgId upTo);
void updateShowFrom();
MsgId inboxRead(MsgId upTo);
MsgId inboxRead(HistoryItem *wasRead);
@ -267,9 +267,9 @@ public:
HistoryItem *lastImportantMessage() const;
void setUnreadCount(int32 newUnreadCount, bool psUpdate = true);
void setUnreadCount(int newUnreadCount, bool psUpdate = true);
void setMute(bool newMute);
void getNextShowFrom(HistoryBlock *block, int32 i);
void getNextShowFrom(HistoryBlock *block, int i);
void addUnreadBar();
void destroyUnreadBar();
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 *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 *addMessageGroupAfterPrevToBlock(const MTPDmessageGroup &group, HistoryItem *prev, HistoryBlock *block);
HistoryItem *addMessageGroupAfterPrev(HistoryItem *newItem, HistoryItem *prev);
HistoryItem *addNewInTheMiddle(HistoryItem *newItem, int32 blockIndex, int32 itemIndex);
HistoryBlock *addNewLastBlock();
HistoryBlock *addNewFirstBlock();
HistoryBlock *pushBackNewBlock();
HistoryBlock *pushFrontNewBlock();
};

View File

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

View File

@ -197,6 +197,8 @@ private:
PopupMenu *_menu;
int _visibleAreaTop = 0;
};
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) {
if (!MTP::authedId()) return;
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 {
// _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
FILEVERSION 0,9,34,0
PRODUCTVERSION 0,9,34,0
FILEVERSION 0,9,34,1
PRODUCTVERSION 0,9,34,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.9.34.0"
VALUE "FileVersion", "0.9.34.1"
VALUE "LegalCopyright", "Copyright (C) 2014-2016"
VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.9.34.0"
VALUE "ProductVersion", "0.9.34.1"
END
END
BLOCK "VarFileInfo"

View File

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