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); _forwardCancel->moveToLeft(0, filterAreaTop);
filterAreaTop += st::dialogsForwardHeight; 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 filterLeft = st::dialogsFilterPadding.x() + _mainMenuToggle->width() + st::dialogsFilterPadding.x();
auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + 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 filterWidth = qMax(width(), st::dialogsWidthMin) - filterLeft - filterRight;
auto filterAreaHeight = st::dialogsFilterPadding.y() + _mainMenuToggle->height() + st::dialogsFilterPadding.y(); auto filterAreaHeight = st::dialogsFilterPadding.y() + _mainMenuToggle->height() + st::dialogsFilterPadding.y();
auto filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2; auto filterTop = filterAreaTop + (filterAreaHeight - _filter->height()) / 2;
filterLeft = anim::interpolate(filterLeft, smallLayoutWidth, smallLayoutRatio);
_filter->setGeometryToLeft(filterLeft, filterTop, filterWidth, _filter->height()); _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()); _lockUnlock->moveToLeft(filterLeft + filterWidth + st::dialogsFilterPadding.x(), filterAreaTop + st::dialogsFilterPadding.y());
_cancelSearch->moveToLeft(filterLeft + filterWidth - _cancelSearch->width(), _filter->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 "styles/style_dialogs.h"
#include "data/data_drafts.h" #include "data/data_drafts.h"
#include "lang.h" #include "lang.h"
#include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "localstorage.h" #include "localstorage.h"
@ -119,6 +120,7 @@ void History::takeLocalDraft(History *from) {
_localDraft->msgId = 0; _localDraft->msgId = 0;
} }
from->clearLocalDraft(); from->clearLocalDraft();
App::api()->saveDraftToCloudDelayed(from);
} }
} }

View File

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

View File

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

View File

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