Small layout search field hidden. Crash fix in common groups section.

Also clearing cloud drafts in deactivated chats after migrating them.
This commit is contained in:
John Preston 2017-01-18 13:26:33 +03:00
parent 8f31e1ab31
commit 8bb14f4565
5 changed files with 42 additions and 16 deletions

View File

@ -2692,13 +2692,17 @@ void DialogsWidget::updateControlsGeometry() {
_forwardCancel->moveToLeft(0, filterAreaTop);
filterAreaTop += st::dialogsForwardHeight;
}
auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x());
auto smallLayoutRatio = (width() < st::dialogsWidthMin) ? (st::dialogsWidthMin - width()) / float64(st::dialogsWidthMin - smallLayoutWidth) : 0.;
auto filterLeft = st::dialogsFilterPadding.x() + _mainMenuToggle->width() + st::dialogsFilterPadding.x();
auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x();
auto filterWidth = qMax(width(), st::dialogsWidthMin) - filterLeft - filterRight;
auto filterAreaHeight = st::dialogsFilterPadding.y() + _mainMenuToggle->height() + st::dialogsFilterPadding.y();
auto filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2;
filterLeft = anim::interpolate(filterLeft, smallLayoutWidth, smallLayoutRatio);
_filter->setGeometryToLeft(filterLeft, filterTop, filterWidth, _filter->height());
_mainMenuToggle->moveToLeft(st::dialogsFilterPadding.x(), filterAreaTop + st::dialogsFilterPadding.y());
auto mainMenuLeft = anim::interpolate(st::dialogsFilterPadding.x(), (smallLayoutWidth - _mainMenuToggle->width()) / 2, smallLayoutRatio);
_mainMenuToggle->moveToLeft(mainMenuLeft, filterAreaTop + st::dialogsFilterPadding.y());
_lockUnlock->moveToLeft(filterLeft + filterWidth + st::dialogsFilterPadding.x(), filterAreaTop + st::dialogsFilterPadding.y());
_cancelSearch->moveToLeft(filterLeft + filterWidth - _cancelSearch->width(), _filter->y());

View File

@ -26,6 +26,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "styles/style_dialogs.h"
#include "data/data_drafts.h"
#include "lang.h"
#include "apiwrap.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "localstorage.h"
@ -119,6 +120,7 @@ void History::takeLocalDraft(History *from) {
_localDraft->msgId = 0;
}
from->clearLocalDraft();
App::api()->saveDraftToCloudDelayed(from);
}
}

View File

@ -236,19 +236,30 @@ void HistoryInner::enumerateItemsInHistory(History *history, int historytop, Met
if (TopToBottom) {
if (itembottom <= _visibleAreaTop && (cAlphaVersion() || cBetaVersion())) {
// Debugging a crash
auto fields = QStringList();
fields.append(QString::number(historytop));
fields.append(QString::number(history->height));
fields.append(QString::number(_visibleAreaTop));
fields.append(QString::number(_visibleAreaBottom));
fields.append(QString::number(blocktop));
fields.append(QString::number(block->height));
fields.append(QString::number(itemtop));
fields.append(QString::number(item->height()));
fields.append(QString::number(itembottom));
fields.append(QString::number(history->blocks.size()));
fields.append(QString::number(block->items.size()));
SignalHandlers::setCrashAnnotation("ItemInfo1", fields.join(','));
auto debugInfo = QStringList();
auto debugValue = [&debugInfo](const QString &name, int value) {
debugInfo.append(name + ":" + QString::number(value));
};
debugValue("historytop", historytop);
debugValue("history->height", history->height);
debugValue("blockIndex", blockIndex);
debugValue("history->blocks.size()", history->blocks.size());
debugValue("blocktop", blocktop);
debugValue("block->height", block->height);
debugValue("itemIndex", itemIndex);
debugValue("block->items.size()", block->items.size());
debugValue("itemtop", itemtop);
debugValue("item->height()", item->height());
debugValue("itembottom", itembottom);
debugValue("_visibleAreaTop", _visibleAreaTop);
debugValue("_visibleAreaBottom", _visibleAreaBottom);
for (int i = 0; i != qMin(history->blocks.size(), 10); ++i) {
for (int j = 0; j != qMin(history->blocks[i]->items.size(), 10); ++j) {
debugValue("y[" + QString::number(i) + "][" + QString::number(j) + "]", history->blocks[i]->items[j]->y);
debugValue("h[" + QString::number(i) + "][" + QString::number(j) + "]", history->blocks[i]->items[j]->height());
}
}
SignalHandlers::setCrashAnnotation("DebugInfo", debugInfo.join(','));
}
t_assert(itembottom > _visibleAreaTop);
} else {

View File

@ -3626,6 +3626,11 @@ void readSavedGifs() {
void writeBackground(int32 id, const QImage &img) {
if (!_working() || !_backgroundCanWrite) return;
if (!_localKey.created()) {
LOG(("App Error: localkey not created in writeBackground()"));
return;
}
QByteArray bmp;
if (!img.isNull()) {
QBuffer buf(&bmp);

View File

@ -140,7 +140,9 @@ void InnerWidget::restoreState(const SectionMemento *memento) {
void InnerWidget::showInitial(const QList<PeerData*> &list) {
for_const (auto group, list) {
_items.push_back(computeItem(group));
if (auto item = computeItem(group)) {
_items.push_back(item);
}
_preloadGroupId = group->bareId();
}
updateSize();
@ -171,7 +173,9 @@ void InnerWidget::preloadMore() {
}
}
if (!found) {
_items.push_back(computeItem(chat));
if (auto item = computeItem(chat)) {
_items.push_back(item);
}
}
_preloadGroupId = chat->bareId();
_allLoaded = false;