diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index d05f7de46..35d1ebca2 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -689,6 +689,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org "lng_stickers_packs" = "Sticker Packs"; "lng_stickers_reorder" = "Click and drag to reorder sticker packs"; "lng_stickers_featured" = "Featured Stickers"; +"lng_stickers_clear_recent" = "Clear"; +"lng_stickers_clear_recent_sure" = "Are you sure you want to clear your frequently used stickers list?"; "lng_stickers_remove" = "Delete"; "lng_stickers_return" = "Undo"; "lng_stickers_restore" = "Restore"; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index e6c12b071..8d3a886c9 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -937,7 +937,7 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result) it->hash = s.vhash.v; it->shortName = qs(s.vshort_name); it->title = stickerSetTitle(s); - auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded); + auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special); it->flags = s.vflags.v | clientFlags; it->flags &= ~MTPDstickerSet_ClientFlag::f_not_loaded; diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index ee5b159b7..0c61a589d 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2012,6 +2012,7 @@ namespace { Global::SetStickerSets(Stickers::Sets()); Global::SetStickerSetsOrder(Stickers::Order()); Global::SetLastStickersUpdate(0); + Global::SetLastRecentStickersUpdate(0); Global::SetFeaturedStickerSetsOrder(Stickers::Order()); Global::SetFeaturedStickerSetsUnreadCount(0); Global::SetLastFeaturedStickersUpdate(0); diff --git a/Telegram/SourceFiles/boxes/stickersetbox.cpp b/Telegram/SourceFiles/boxes/stickersetbox.cpp index 18d5a9741..a55c26bb7 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.cpp +++ b/Telegram/SourceFiles/boxes/stickersetbox.cpp @@ -87,7 +87,7 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) { auto &sets = Global::RefStickerSets(); auto it = sets.find(_setId); if (it != sets.cend()) { - auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_unread); + auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_special); _setFlags |= clientFlags; it->flags = _setFlags; it->stickers = _pack; @@ -418,6 +418,7 @@ StickersInner::StickersInner(StickersBox::Section section) : TWidget() , _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom()) , _a_shifting(animation(this, &StickersInner::step_shifting)) , _itemsTop(st::membersPadding.top()) +, _clearWidth(st::normalFont->width(lang(lng_stickers_clear_recent))) , _removeWidth(st::normalFont->width(lang(lng_stickers_remove))) , _returnWidth(st::normalFont->width(lang(lng_stickers_return))) , _restoreWidth(st::normalFont->width(lang(lng_stickers_restore))) @@ -500,8 +501,8 @@ void StickersInner::paintRow(Painter &p, int32 index) { } else { p.setPen(st::btnDefLink.color); } - int32 remWidth = s->disabled ? (s->official ? _restoreWidth : _returnWidth) : _removeWidth; - QString remText = lang(s->disabled ? (s->official ? lng_stickers_restore : lng_stickers_return) : lng_stickers_remove); + int32 remWidth = s->recent ? _clearWidth : (s->disabled ? (s->official ? _restoreWidth : _returnWidth) : _removeWidth); + QString remText = lang(s->recent ? lng_stickers_clear_recent : (s->disabled ? (s->official ? lng_stickers_restore : lng_stickers_return) : lng_stickers_remove)); p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), remText, remWidth); if (index == _above) { @@ -581,7 +582,7 @@ void StickersInner::mousePressEvent(QMouseEvent *e) { if (_actionSel >= 0) { _actionDown = _actionSel; update(0, _itemsTop + _actionSel * _rowHeight, width(), _rowHeight); - } else if (_selected >= 0 && _section == Section::Installed) { + } else if (_selected >= 0 && _section == Section::Installed && !_rows.at(_selected)->recent) { _above = _dragging = _started = _selected; _dragStart = mapFromGlobal(_mouse); } @@ -599,8 +600,12 @@ void StickersInner::onUpdateSelected() { if (_dragging >= 0) { int32 shift = 0; uint64 ms = getms(); + int firstSetIndex = 0; + if (_rows.at(firstSetIndex)->recent) { + ++firstSetIndex; + } if (_dragStart.y() > local.y() && _dragging > 0) { - shift = -floorclamp(_dragStart.y() - local.y() + (_rowHeight / 2), _rowHeight, 0, _dragging); + shift = -floorclamp(_dragStart.y() - local.y() + (_rowHeight / 2), _rowHeight, 0, _dragging - firstSetIndex); for (int32 from = _dragging, to = _dragging + shift; from > to; --from) { qSwap(_rows[from], _rows[from - 1]); _rows.at(from)->yadd = anim::ivalue(_rows.at(from)->yadd.current() - _rowHeight, 0); @@ -635,7 +640,7 @@ void StickersInner::onUpdateSelected() { selected = floorclamp(local.y() - _itemsTop, _rowHeight, 0, _rows.size() - 1); if (_section == Section::Installed) { - int remw = _rows.at(selected)->disabled ? (_rows.at(selected)->official ? _restoreWidth : _returnWidth) : _removeWidth; + int remw = _rows.at(selected)->recent ? _clearWidth : (_rows.at(selected)->disabled ? (_rows.at(selected)->official ? _restoreWidth : _returnWidth) : _removeWidth); QRect rem(myrtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - remw, st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, remw, st::normalFont->height)); actionSel = rem.contains(local.x(), local.y() - _itemsTop - selected * _rowHeight) ? selected : -1; } else if (_rows.at(selected)->installed) { @@ -666,6 +671,34 @@ void StickersInner::onUpdateSelected() { } } +void StickersInner::onClearRecent() { + if (_clearBox) { + _clearBox->onClose(); + } + + auto &sets = Global::RefStickerSets(); + sets.remove(Stickers::CloudRecentSetId); + sets.remove(Stickers::CustomSetId); + + auto &recent = cGetRecentStickers(); + if (!recent.isEmpty()) { + recent.clear(); + Local::writeUserSettings(); + } + + Local::writeStickers(); + emit App::main()->updateStickers(); + rebuild(); + + MTP::send(MTPmessages_ClearRecentStickers()); +} + +void StickersInner::onClearBoxDestroyed(QObject *box) { + if (box == _clearBox) { + _clearBox = nullptr; + } +} + float64 StickersInner::aboveShadowOpacity() const { if (_above < 0) return 0; @@ -688,7 +721,14 @@ void StickersInner::mouseReleaseEvent(QMouseEvent *e) { onUpdateSelected(); if (_actionDown == _actionSel && _actionSel >= 0) { if (_section == Section::Installed) { - _rows[_actionDown]->disabled = !_rows[_actionDown]->disabled; + if (_rows[_actionDown]->recent) { + _clearBox = new ConfirmBox(lang(lng_stickers_clear_recent_sure), lang(lng_stickers_clear_recent)); + connect(_clearBox, SIGNAL(confirmed()), this, SLOT(onClearRecent())); + connect(_clearBox, SIGNAL(destroyed(QObject*)), this, SLOT(onClearBoxDestroyed(QObject*))); + Ui::showLayer(_clearBox, KeepOtherLayers); + } else { + _rows[_actionDown]->disabled = !_rows[_actionDown]->disabled; + } } else { installSet(_rows[_actionDown]->id); } @@ -876,7 +916,7 @@ void StickersInner::rebuild() { int namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left(); int namew = st::boxWideWidth - namex - st::contactsPadding.right() - st::contactsCheckPosition.x(); if (_section == Section::Installed) { - namew -= qMax(qMax(_returnWidth, _removeWidth), _restoreWidth); + namew -= qMax(qMax(qMax(_returnWidth, _removeWidth), _restoreWidth), _clearWidth); } else { namew -= _addWidth - st::defaultActiveButton.width; } @@ -886,12 +926,54 @@ void StickersInner::rebuild() { _animStartTimes.reserve(order.size()); auto &sets = Global::StickerSets(); + auto cloudIt = sets.constFind(Stickers::CloudRecentSetId); + if (cloudIt != sets.cend() && !cloudIt->stickers.isEmpty()) { + DocumentData *sticker = cloudIt->stickers.at(0); + int32 pixw = 0, pixh = 0; + if (sticker) { + pixw = sticker->thumb->width(); + pixh = sticker->thumb->height(); + if (pixw > st::contactsPhotoSize) { + if (pixw > pixh) { + pixh = (pixh * st::contactsPhotoSize) / pixw; + pixw = st::contactsPhotoSize; + } else { + pixw = (pixw * st::contactsPhotoSize) / pixh; + pixh = st::contactsPhotoSize; + } + } else if (pixh > st::contactsPhotoSize) { + pixw = (pixw * st::contactsPhotoSize) / pixh; + pixh = st::contactsPhotoSize; + } + } + QString title = cloudIt->title; + int32 titleWidth = st::contactsNameFont->width(title); + if (titleWidth > namew) { + title = st::contactsNameFont->elided(title, namew); + } + int count = cloudIt->stickers.size(); + int added = 0; + auto customIt = sets.constFind(Stickers::CustomSetId); + if (customIt != sets.cend()) { + added = customIt->stickers.size(); + for_const (auto &sticker, cGetRecentStickers()) { + if (customIt->stickers.indexOf(sticker.first) < 0) { + ++added; + } + } + } else { + added = cGetRecentStickers().size(); + } + rows.push_back(new StickerSetRow(cloudIt->id, cloudIt->stickers.front(), count + added, title, true, true, false, false, true, pixw, pixh)); + _animStartTimes.push_back(0); + } for_const (auto setId, order) { auto it = sets.constFind(setId); if (it == sets.cend()) { continue; } + bool recent = false; bool installed = (it->flags & MTPDstickerSet::Flag::f_installed); bool disabled = (_section == Section::Installed) && (it->flags & MTPDstickerSet::Flag::f_disabled); bool official = (it->flags & MTPDstickerSet::Flag::f_official); @@ -924,7 +1006,7 @@ void StickersInner::rebuild() { if (titleWidth > namew) { title = st::contactsNameFont->elided(title, namew); } - (disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, installed, official, unread, disabled, pixw, pixh)); + (disabled ? rowsDisabled : rows).push_back(new StickerSetRow(it->id, sticker, it->stickers.size(), title, installed, official, unread, disabled, recent, pixw, pixh)); _animStartTimes.push_back(0); if (it->stickers.isEmpty() || (it->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) { App::api()->scheduleStickerSetRequest(it->id, it->access); @@ -973,6 +1055,9 @@ QVector StickersInner::getOrder() const { continue; } } + if (_rows.at(i)->recent) { + continue; + } result.push_back(_rows.at(i)->id); } return result; @@ -1167,7 +1252,7 @@ void StickersBox::onSave() { } bool writeRecent = false; - RecentStickerPack &recent(cGetRecentStickers()); + auto &recent = cGetRecentStickers(); auto &sets = Global::RefStickerSets(); QVector reorder = _inner->getOrder(), disabled = _inner->getDisabledSets(); @@ -1191,7 +1276,7 @@ void StickersBox::onSave() { _disenableRequests.insert(MTP::send(MTPmessages_UninstallStickerSet(setId), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType()); int removeIndex = Global::StickerSetsOrder().indexOf(it->id); if (removeIndex >= 0) Global::RefStickerSetsOrder().removeAt(removeIndex); - if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured)) { + if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured) && !(it->flags & MTPDstickerSet_ClientFlag::f_special)) { sets.erase(it); } else { it->flags &= ~(MTPDstickerSet::Flag::f_installed | MTPDstickerSet::Flag::f_disabled); @@ -1221,10 +1306,9 @@ void StickersBox::onSave() { } } for (auto it = sets.begin(); it != sets.cend();) { - if (it->id == Stickers::CustomSetId - || it->id == Stickers::RecentSetId - || (it->flags & MTPDstickerSet_ClientFlag::f_featured) - || (it->flags & MTPDstickerSet::Flag::f_installed)) { + if ((it->flags & MTPDstickerSet_ClientFlag::f_featured) + || (it->flags & MTPDstickerSet::Flag::f_installed) + || (it->flags & MTPDstickerSet_ClientFlag::f_special)) { ++it; } else { it = sets.erase(it); diff --git a/Telegram/SourceFiles/boxes/stickersetbox.h b/Telegram/SourceFiles/boxes/stickersetbox.h index 28bddfac0..70f65e3c3 100644 --- a/Telegram/SourceFiles/boxes/stickersetbox.h +++ b/Telegram/SourceFiles/boxes/stickersetbox.h @@ -22,6 +22,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org #include "abstractbox.h" +class ConfirmBox; + class StickerSetInner : public TWidget, public RPCSender { Q_OBJECT @@ -221,6 +223,8 @@ signals: public slots: void onUpdateSelected(); + void onClearRecent(); + void onClearBoxDestroyed(QObject *box); private: void paintFeaturedButton(Painter &p) const; @@ -240,7 +244,7 @@ private: int32 _rowHeight; struct StickerSetRow { - StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool installed, bool official, bool unread, bool disabled, int32 pixw, int32 pixh) : id(id) + StickerSetRow(uint64 id, DocumentData *sticker, int32 count, const QString &title, bool installed, bool official, bool unread, bool disabled, bool recent, int32 pixw, int32 pixh) : id(id) , sticker(sticker) , count(count) , title(title) @@ -248,6 +252,7 @@ private: , official(official) , unread(unread) , disabled(disabled) + , recent(recent) , pixw(pixw) , pixh(pixh) , yadd(0, 0) { @@ -256,7 +261,7 @@ private: DocumentData *sticker; int32 count; QString title; - bool installed, official, unread, disabled; + bool installed, official, unread, disabled, recent; int32 pixw, pixh; anim::ivalue yadd; }; @@ -274,7 +279,9 @@ private: int _actionSel = -1; int _actionDown = -1; - int _removeWidth, _returnWidth, _restoreWidth; + int _clearWidth, _removeWidth, _returnWidth, _restoreWidth; + + ConfirmBox *_clearBox = nullptr; QString _addText; int _addWidth; diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index 029c912a7..1c63f49ba 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -714,7 +714,7 @@ void EmojiColorPicker::drawVariant(Painter &p, int variant) { } EmojiPanInner::EmojiPanInner() : TWidget() -, _maxHeight(int(st::emojiPanMaxHeight)) +, _maxHeight(int(st::emojiPanMaxHeight) - st::rbEmoji.height) , _a_selected(animation(this, &EmojiPanInner::step_selected)) , _top(0) , _selected(-1) @@ -1230,7 +1230,7 @@ StickerPanInner::StickerPanInner() : TWidget() , _pressedSel(-1) , _settings(this, lang(lng_stickers_you_have)) , _previewShown(false) { - setMaxHeight(st::emojiPanMaxHeight); + setMaxHeight(st::emojiPanMaxHeight - st::rbEmoji.height); setMouseTracking(true); setFocusPolicy(Qt::NoFocus); @@ -2111,37 +2111,49 @@ void StickerPanInner::refreshRecent() { void StickerPanInner::refreshRecentStickers(bool performResize) { _custom.clear(); clearSelection(true); - auto customIt = Global::StickerSets().constFind(Stickers::CustomSetId); - if (cGetRecentStickers().isEmpty() && (customIt == Global::StickerSets().cend() || customIt->stickers.isEmpty())) { + auto &sets = Global::StickerSets(); + auto &recent = cGetRecentStickers(); + auto customIt = sets.constFind(Stickers::CustomSetId); + auto cloudIt = sets.constFind(Stickers::CloudRecentSetId); + if (recent.isEmpty() + && (customIt == sets.cend() || customIt->stickers.isEmpty()) + && (cloudIt == sets.cend() || cloudIt->stickers.isEmpty())) { if (!_sets.isEmpty() && _sets.at(0).id == Stickers::RecentSetId) { _sets.pop_front(); } } else { - StickerPack recent; - int32 customCnt = (customIt == Global::StickerSets().cend() ? 0 : customIt->stickers.size()); - QMap recentOnly; - recent.reserve(cGetRecentStickers().size() + customCnt); - _custom.reserve(cGetRecentStickers().size() + customCnt); - for (int32 i = 0, l = cGetRecentStickers().size(); i < l; ++i) { - DocumentData *s = cGetRecentStickers().at(i).first; - recent.push_back(s); - recentOnly.insert(s, true); + StickerPack recentPack; + int customCnt = (customIt == sets.cend()) ? 0 : customIt->stickers.size(); + int cloudCnt = (cloudIt == sets.cend()) ? 0 : cloudIt->stickers.size(); + recentPack.reserve(cloudCnt + recent.size() + customCnt); + _custom.reserve(cloudCnt + recent.size() + customCnt); + if (cloudCnt > 0) { + for_const (auto sticker, cloudIt->stickers) { + recentPack.push_back(sticker); + _custom.push_back(false); + } + } + for_const (auto &recentSticker, recent) { + auto sticker = recentSticker.first; + recentPack.push_back(sticker); _custom.push_back(false); } - for (int32 i = 0; i < customCnt; ++i) { - DocumentData *s = customIt->stickers.at(i); - if (recentOnly.contains(s)) { - _custom[recent.indexOf(s)] = true; - } else { - recent.push_back(s); - _custom.push_back(true); + if (customCnt > 0) { + for_const (auto &sticker, customIt->stickers) { + auto index = recentPack.indexOf(sticker); + if (index >= cloudCnt) { + _custom[index] = true; // mark stickers from recent as custom + } else { + recentPack.push_back(sticker); + _custom.push_back(true); + } } } if (_sets.isEmpty() || _sets.at(0).id != Stickers::RecentSetId) { - _sets.push_back(DisplayedSet(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official, lang(lng_emoji_category0), recent.size() * 2, recent)); + _sets.push_back(DisplayedSet(Stickers::RecentSetId, MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special, lang(lng_emoji_category0), recentPack.size() * 2, recentPack)); } else { - _sets[0].pack = recent; - _sets[0].hovers.resize(recent.size() * 2); + _sets[0].pack = recentPack; + _sets[0].hovers.resize(recentPack.size() * 2); } } @@ -3244,7 +3256,7 @@ void EmojiPan::step_icons(uint64 ms, bool timer) { } if (_iconsStartAnim) { - float64 dt = (ms - _iconsStartAnim) / st::stickerIconMove; + float64 dt = (ms - _iconsStartAnim) / float64(st::stickerIconMove); if (dt >= 1) { _iconsStartAnim = 0; _iconsX.finish(); @@ -3669,7 +3681,7 @@ void EmojiPan::onRemoveSetSure() { } } it->flags &= ~MTPDstickerSet::Flag::f_installed; - if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured)) { + if (!(it->flags & MTPDstickerSet_ClientFlag::f_featured) && !(it->flags & MTPDstickerSet_ClientFlag::f_special)) { Global::RefStickerSets().erase(it); } int removeIndex = Global::StickerSetsOrder().indexOf(_removingSetId); diff --git a/Telegram/SourceFiles/facades.cpp b/Telegram/SourceFiles/facades.cpp index 7dfa5513c..d4e7318c0 100644 --- a/Telegram/SourceFiles/facades.cpp +++ b/Telegram/SourceFiles/facades.cpp @@ -564,6 +564,7 @@ struct Data { Stickers::Sets StickerSets; Stickers::Order StickerSetsOrder; uint64 LastStickersUpdate = 0; + uint64 LastRecentStickersUpdate = 0; Stickers::Order FeaturedStickerSetsOrder; int FeaturedStickerSetsUnreadCount = 0; uint64 LastFeaturedStickersUpdate = 0; @@ -635,6 +636,7 @@ DefineRefVar(Global, PendingItemsMap, PendingRepaintItems); DefineVar(Global, Stickers::Sets, StickerSets); DefineVar(Global, Stickers::Order, StickerSetsOrder); DefineVar(Global, uint64, LastStickersUpdate); +DefineVar(Global, uint64, LastRecentStickersUpdate); DefineVar(Global, Stickers::Order, FeaturedStickerSetsOrder); DefineVar(Global, int, FeaturedStickerSetsUnreadCount); DefineVar(Global, uint64, LastFeaturedStickersUpdate); diff --git a/Telegram/SourceFiles/facades.h b/Telegram/SourceFiles/facades.h index cd9acceeb..d0d09ff29 100644 --- a/Telegram/SourceFiles/facades.h +++ b/Telegram/SourceFiles/facades.h @@ -183,8 +183,10 @@ enum Flags { namespace Stickers { static const uint64 DefaultSetId = 0; // for backward compatibility -static const uint64 CustomSetId = 0xFFFFFFFFFFFFFFFFULL, RecentSetId = 0xFFFFFFFFFFFFFFFEULL; -static const uint64 NoneSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel +static const uint64 CustomSetId = 0xFFFFFFFFFFFFFFFFULL; +static const uint64 RecentSetId = 0xFFFFFFFFFFFFFFFEULL; // for emoji/stickers panel, should not appear in Sets +static const uint64 NoneSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel, should not appear in Sets +static const uint64 CloudRecentSetId = 0xFFFFFFFFFFFFFFFCULL; // for cloud-stored recent stickers struct Set { Set(uint64 id, uint64 access, const QString &title, const QString &shortName, int32 count, int32 hash, MTPDstickerSet::Flags flags) : id(id) @@ -262,6 +264,7 @@ DeclareRefVar(PendingItemsMap, PendingRepaintItems); DeclareVar(Stickers::Sets, StickerSets); DeclareVar(Stickers::Order, StickerSetsOrder); DeclareVar(uint64, LastStickersUpdate); +DeclareVar(uint64, LastRecentStickersUpdate); DeclareVar(Stickers::Order, FeaturedStickerSetsOrder); DeclareVar(int, FeaturedStickerSetsUnreadCount); DeclareVar(uint64, LastFeaturedStickersUpdate); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index a5c8b8bd2..9534dd746 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -4076,10 +4076,10 @@ void HistoryDocument::draw(Painter &p, const QRect &r, TextSelection selection, bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, _width)); - QPixmap thumb = loaded ? _data->thumb->pixSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize); + QPixmap thumb = loaded ? _data->thumb->pixSingle(ImageRoundRadius::Large, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize) : _data->thumb->pixBlurredSingle(ImageRoundRadius::Small, thumbed->_thumbw, 0, st::msgFileThumbSize, st::msgFileThumbSize); p.drawPixmap(rthumb.topLeft(), thumb); if (selected) { - App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlaySmallCorners); + App::roundRect(p, rthumb, textstyleCurrent()->selectOverlay, SelectedOverlayLargeCorners); } if (radial || (!loaded && !_data->loading())) { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 27f01b9a4..08523d689 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -3530,6 +3530,11 @@ void HistoryWidget::updateStickers() { _stickersUpdateRequest = MTP::send(MTPmessages_GetAllStickers(MTP_int(Local::countStickersHash(true))), rpcDone(&HistoryWidget::stickersGot), rpcFail(&HistoryWidget::stickersFailed)); } } + if (!Global::LastRecentStickersUpdate() || now >= Global::LastRecentStickersUpdate() + StickersUpdateTimeout) { + if (!_recentStickersUpdateRequest) { + _recentStickersUpdateRequest = MTP::send(MTPmessages_GetRecentStickers(MTP_int(Local::countRecentStickersHash())), rpcDone(&HistoryWidget::recentStickersGot), rpcFail(&HistoryWidget::recentStickersFailed)); + } + } if (!Global::LastFeaturedStickersUpdate() || now >= Global::LastFeaturedStickersUpdate() + StickersUpdateTimeout) { if (!_featuredStickersUpdateRequest) { _featuredStickersUpdateRequest = MTP::send(MTPmessages_GetFeaturedStickers(MTP_int(Local::countFeaturedStickersHash())), rpcDone(&HistoryWidget::featuredStickersGot), rpcFail(&HistoryWidget::featuredStickersFailed)); @@ -3671,7 +3676,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) { it->access = set.vaccess_hash.v; it->title = title; it->shortName = qs(set.vshort_name); - auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded); + auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special); it->flags = set.vflags.v | clientFlags; if (it->count != set.vcount.v || it->hash != set.vhash.v || it->emoji.isEmpty()) { it->count = set.vcount.v; @@ -3692,6 +3697,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) { for (Stickers::Sets::iterator it = sets.begin(), e = sets.end(); it != e;) { bool installed = (it->flags & MTPDstickerSet::Flag::f_installed); bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured); + bool special = (it->flags & MTPDstickerSet_ClientFlag::f_special); if (!installed) { // remove not mine sets from recent stickers for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) { if (it->stickers.indexOf(i->first) >= 0) { @@ -3702,7 +3708,7 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) { } } } - if (installed || featured) { + if (installed || featured || special) { ++it; } else { it = sets.erase(it); @@ -3736,6 +3742,92 @@ bool HistoryWidget::stickersFailed(const RPCError &error) { return true; } +void HistoryWidget::recentStickersGot(const MTPmessages_RecentStickers &stickers) { + Global::SetLastRecentStickersUpdate(getms(true)); + _recentStickersUpdateRequest = 0; + + if (stickers.type() != mtpc_messages_recentStickers) return; + auto &d = stickers.c_messages_recentStickers(); + + auto &sets = Global::RefStickerSets(); + auto it = sets.find(Stickers::CloudRecentSetId); + + auto &d_docs = d.vstickers.c_vector().v; + if (d_docs.isEmpty()) { + if (it != sets.cend()) { + sets.erase(it); + } + } else { + if (it == sets.cend()) { + it = sets.insert(Stickers::CloudRecentSetId, Stickers::Set(Stickers::CloudRecentSetId, 0, lang(lng_emoji_category0), QString(), 0, 0, qFlags(MTPDstickerSet_ClientFlag::f_special))); + } else { + it->title = lang(lng_emoji_category0); + } + it->hash = d.vhash.v; + + auto custom = sets.find(Stickers::CustomSetId); + + StickerPack pack; + pack.reserve(d_docs.size()); + for (int32 i = 0, l = d_docs.size(); i != l; ++i) { + DocumentData *doc = App::feedDocument(d_docs.at(i)); + if (!doc || !doc->sticker()) continue; + + pack.push_back(doc); + if (custom != sets.cend()) { + int32 index = custom->stickers.indexOf(doc); + if (index >= 0) { + custom->stickers.removeAt(index); + } + } + } + if (custom != sets.cend() && custom->stickers.isEmpty()) { + sets.erase(custom); + custom = sets.end(); + } + + bool writeRecent = false; + RecentStickerPack &recent(cGetRecentStickers()); + for (RecentStickerPack::iterator i = recent.begin(); i != recent.cend();) { + if (it->stickers.indexOf(i->first) >= 0 && pack.indexOf(i->first) < 0) { + i = recent.erase(i); + writeRecent = true; + } else { + ++i; + } + } + + if (pack.isEmpty()) { + sets.erase(it); + } else { + it->stickers = pack; + it->emoji.clear(); + } + + if (writeRecent) { + Local::writeUserSettings(); + } + } + + if (Local::countRecentStickersHash() != d.vhash.v) { + LOG(("API Error: received stickers hash %1 while counted hash is %2").arg(d.vhash.v).arg(Local::countRecentStickersHash())); + } + + Local::writeStickers(); + + if (App::main()) emit App::main()->stickersUpdated(); +} + +bool HistoryWidget::recentStickersFailed(const RPCError &error) { + if (MTP::isDefaultHandledError(error)) return false; + + LOG(("App Fail: Failed to get recent stickers!")); + + Global::SetLastRecentStickersUpdate(getms(true)); + _recentStickersUpdateRequest = 0; + return true; +} + void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stickers) { Global::SetLastFeaturedStickersUpdate(getms(true)); _featuredStickersUpdateRequest = 0; @@ -3764,16 +3856,16 @@ void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stic auto it = sets.find(set.vid.v); QString title = stickerSetTitle(set); if (it == sets.cend()) { - auto clientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded; + auto setClientFlags = MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_not_loaded; if (unread.contains(set.vid.v) || !(set.vflags.v & MTPDstickerSet::Flag::f_installed)) { - clientFlags |= MTPDstickerSet_ClientFlag::f_unread; + setClientFlags |= MTPDstickerSet_ClientFlag::f_unread; } - it = sets.insert(set.vid.v, Stickers::Set(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | clientFlags)); + it = sets.insert(set.vid.v, Stickers::Set(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | setClientFlags)); } else { it->access = set.vaccess_hash.v; it->title = title; it->shortName = qs(set.vshort_name); - auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded); + auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special); it->flags = set.vflags.v | clientFlags; it->flags |= MTPDstickerSet_ClientFlag::f_featured; if (unread.contains(it->id)) { @@ -3798,7 +3890,8 @@ void HistoryWidget::featuredStickersGot(const MTPmessages_FeaturedStickers &stic for (auto it = sets.begin(), e = sets.end(); it != e;) { bool installed = (it->flags & MTPDstickerSet::Flag::f_installed); bool featured = (it->flags & MTPDstickerSet_ClientFlag::f_featured); - if (installed || featured) { + bool special = (it->flags & MTPDstickerSet_ClientFlag::f_special); + if (installed || featured || special) { if (featured && (it->flags & MTPDstickerSet_ClientFlag::f_unread)) { ++unreadCount; } diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index ff68e4e3e..ee979a570 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -1005,6 +1005,10 @@ private: void stickersGot(const MTPmessages_AllStickers &stickers); bool stickersFailed(const RPCError &error); + mtpRequestId _recentStickersUpdateRequest = 0; + void recentStickersGot(const MTPmessages_RecentStickers &stickers); + bool recentStickersFailed(const RPCError &error); + mtpRequestId _featuredStickersUpdateRequest = 0; void featuredStickersGot(const MTPmessages_FeaturedStickers &stickers); bool featuredStickersFailed(const RPCError &error); diff --git a/Telegram/SourceFiles/localstorage.cpp b/Telegram/SourceFiles/localstorage.cpp index b4e1417a9..68a443ca0 100644 --- a/Telegram/SourceFiles/localstorage.cpp +++ b/Telegram/SourceFiles/localstorage.cpp @@ -3052,7 +3052,7 @@ namespace Local { quint32 size = sizeof(quint32) + Serialize::bytearraySize(hashToWrite); for_const (auto &set, sets) { bool notLoaded = (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded); - if (notLoaded) { + if (notLoaded && !(set.flags & MTPDstickerSet_ClientFlag::f_special)) { if (!(set.flags & MTPDstickerSet::Flag::f_disabled) || (set.flags & MTPDstickerSet::Flag::f_official) || (set.flags & MTPDstickerSet_ClientFlag::f_featured)) { // waiting to receive @@ -3118,8 +3118,8 @@ namespace Local { auto &recent = cRefRecentStickers(); recent.clear(); - auto &def = sets.insert(Stickers::DefaultSetId, Stickers::Set(Stickers::DefaultSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::Flag::f_official | MTPDstickerSet::Flag::f_installed)).value(); - auto &custom = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed)).value(); + auto &def = sets.insert(Stickers::DefaultSetId, Stickers::Set(Stickers::DefaultSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::Flag::f_official | MTPDstickerSet::Flag::f_installed | MTPDstickerSet_ClientFlag::f_special)).value(); + auto &custom = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed | MTPDstickerSet_ClientFlag::f_special)).value(); QMap read; while (!stickers.stream.atEnd()) { @@ -3220,12 +3220,16 @@ namespace Local { if (setId == Stickers::DefaultSetId) { setTitle = lang(lng_stickers_default_set); - setFlags |= qFlags(MTPDstickerSet::Flag::f_official); + setFlags |= qFlags(MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special); if (stickers.version < 9058) { order.push_front(setId); } } else if (setId == Stickers::CustomSetId) { setTitle = lang(lng_custom_stickers); + setFlags |= qFlags(MTPDstickerSet_ClientFlag::f_special); + } else if (setId == Stickers::CloudRecentSetId) { + setTitle = lang(lng_emoji_category0); // Frequently used + setFlags |= qFlags(MTPDstickerSet_ClientFlag::f_special); } else if (setId) { if (stickers.version < 9058) { order.push_back(setId); @@ -3328,6 +3332,20 @@ namespace Local { return (!checkOfficial || (!foundBad && foundOfficial)) ? int32(acc & 0x7FFFFFFF) : 0; } + int32 countRecentStickersHash() { + uint32 acc = 0; + auto &sets = Global::StickerSets(); + auto it = sets.constFind(Stickers::CloudRecentSetId); + if (it != sets.cend()) { + for_const (auto doc, it->stickers) { + auto docId = doc->id; + acc = (acc * 20261) + uint32(docId >> 32); + acc = (acc * 20261) + uint32(docId & 0xFFFFFFFF); + } + } + return int32(acc & 0x7FFFFFFF); + } + int32 countFeaturedStickersHash() { uint32 acc = 0; auto &sets = Global::StickerSets(); @@ -3346,10 +3364,9 @@ namespace Local { int32 countSavedGifsHash() { uint32 acc = 0; - const SavedGifs &saved(cSavedGifs()); - for (SavedGifs::const_iterator i = saved.cbegin(), e = saved.cend(); i != e; ++i) { - uint64 docId = (*i)->id; - + auto &saved = cSavedGifs(); + for_const (auto doc, saved) { + auto docId = doc->id; acc = (acc * 20261) + uint32(docId >> 32); acc = (acc * 20261) + uint32(docId & 0xFFFFFFFF); } diff --git a/Telegram/SourceFiles/localstorage.h b/Telegram/SourceFiles/localstorage.h index 204ac320a..a4909037d 100644 --- a/Telegram/SourceFiles/localstorage.h +++ b/Telegram/SourceFiles/localstorage.h @@ -156,6 +156,7 @@ namespace Local { void writeStickers(); void readStickers(); int32 countStickersHash(bool checkOfficial = false); + int32 countRecentStickersHash(); int32 countFeaturedStickersHash(); void writeSavedGifs(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 4b55121dc..3391afaa2 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -301,11 +301,6 @@ void MainWidget::finishForwarding(History *history, bool silent) { FullMsgId newId(peerToChannel(history->peer->id), clientMsgId()); HistoryMessage *msg = static_cast(_toForward.cbegin().value()); history->addNewForwarded(newId.msg, flags, date(MTP_int(unixtime())), showFromName ? MTP::authedId() : 0, msg); - if (HistoryMedia *media = msg->getMedia()) { - if (media->type() == MediaTypeSticker) { - App::main()->incrementSticker(media->getDocument()); - } - } App::historyRegRandom(randomId, newId); } if (forwardFrom != i.value()->history()->peer) { @@ -3679,71 +3674,60 @@ void MainWidget::updateNotifySetting(PeerData *peer, NotifySettingStatus notify, void MainWidget::incrementSticker(DocumentData *sticker) { if (!sticker || !sticker->sticker()) return; + if (sticker->sticker()->set.type() == mtpc_inputStickerSetEmpty) return; - RecentStickerPack &recent(cGetRecentStickers()); - RecentStickerPack::iterator i = recent.begin(), e = recent.end(); - for (; i != e; ++i) { + bool writeStickers = false; + auto &sets = Global::RefStickerSets(); + auto it = sets.find(Stickers::CloudRecentSetId); + if (it == sets.cend()) { + if (it == sets.cend()) { + it = sets.insert(Stickers::CloudRecentSetId, Stickers::Set(Stickers::CloudRecentSetId, 0, lang(lng_emoji_category0), QString(), 0, 0, qFlags(MTPDstickerSet_ClientFlag::f_special))); + } else { + it->title = lang(lng_emoji_category0); + } + } + auto index = it->stickers.indexOf(sticker); + if (index > 0) { + it->stickers.removeAt(index); + } + if (index) { + it->stickers.push_front(sticker); + writeStickers = true; + } + + // Remove that sticker from old recent, now it is in cloud recent stickers. + bool writeRecent = false; + auto &recent = cGetRecentStickers(); + for (auto i = recent.begin(), e = recent.end(); i != e; ++i) { if (i->first == sticker) { - i->second = recent.begin()->second; // throw to the first place - //++i->second; - //if (i->second > 0x8000) { - // for (RecentStickerPack::iterator j = recent.begin(); j != e; ++j) { - // if (j->second > 1) { - // j->second /= 2; - // } else { - // j->second = 1; - // } - // } - //} - for (; i != recent.begin(); --i) { - if ((i - 1)->second > i->second) { - break; - } - qSwap(*i, *(i - 1)); - } + writeRecent = true; + recent.erase(i); break; } } - if (i == e) { - while (recent.size() >= StickerPanPerRow * StickerPanRowsPerPage) recent.pop_back(); - recent.push_front(qMakePair(sticker, recent.isEmpty() ? 1 : recent.begin()->second)); - //recent.push_back(qMakePair(sticker, 1)); - //for (i = recent.end() - 1; i != recent.begin(); --i) { - // if ((i - 1)->second > i->second) { - // break; - // } - // qSwap(*i, *(i - 1)); - //} + while (!recent.isEmpty() && it->stickers.size() + recent.size() > StickerPanPerRow * StickerPanRowsPerPage) { + writeRecent = true; + recent.pop_back(); } - Local::writeUserSettings(); - - bool found = false; - uint64 setId = 0; - QString setName; - switch (sticker->sticker()->set.type()) { - case mtpc_inputStickerSetID: setId = sticker->sticker()->set.c_inputStickerSetID().vid.v; break; - case mtpc_inputStickerSetShortName: setName = qs(sticker->sticker()->set.c_inputStickerSetShortName().vshort_name).toLower().trimmed(); break; + if (writeRecent) { + Local::writeUserSettings(); } - Stickers::Sets &sets(Global::RefStickerSets()); - for (auto i = sets.cbegin(); i != sets.cend(); ++i) { - if (i->id == Stickers::CustomSetId || i->id == Stickers::DefaultSetId || (setId && i->id == setId) || (!setName.isEmpty() && i->shortName.toLower().trimmed() == setName)) { - for (int32 j = 0, l = i->stickers.size(); j < l; ++j) { - if (i->stickers.at(j) == sticker) { - found = true; - break; - } + + // Remove that sticker from custom stickers, now it is in cloud recent stickers. + auto custom = sets.find(Stickers::CustomSetId); + if (custom != sets.cend()) { + int removeIndex = custom->stickers.indexOf(sticker); + if (removeIndex >= 0) { + custom->stickers.removeAt(removeIndex); + if (custom->stickers.isEmpty()) { + sets.erase(custom); } - if (found) break; + writeStickers = true; } } - if (!found) { - Stickers::Sets::iterator it = sets.find(Stickers::CustomSetId); - if (it == sets.cend()) { - it = sets.insert(Stickers::CustomSetId, Stickers::Set(Stickers::CustomSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, MTPDstickerSet::Flag::f_installed)); - } - it->stickers.push_back(sticker); - ++it->count; + + if (writeStickers) { Local::writeStickers(); } _history->updateRecentStickers(); @@ -4770,6 +4754,11 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { App::main()->updateStickers(); } break; + case mtpc_updateRecentStickers: { + Global::SetLastStickersUpdate(0); + App::main()->updateStickers(); + } break; + case mtpc_updateReadFeaturedStickers: { for (auto &set : Global::RefStickerSets()) { if (set.flags & MTPDstickerSet_ClientFlag::f_unread) { diff --git a/Telegram/SourceFiles/mtproto/core_types.h b/Telegram/SourceFiles/mtproto/core_types.h index 1438fe212..846b8ef71 100644 --- a/Telegram/SourceFiles/mtproto/core_types.h +++ b/Telegram/SourceFiles/mtproto/core_types.h @@ -1066,8 +1066,11 @@ enum class MTPDstickerSet_ClientFlag : int32 { // sticker set is an unread featured set f_unread = (1 << 28), + // special set like recent or custom stickers + f_special = (1 << 27), + // update this when adding new client side flags - MIN_FIELD = (1 << 28), + MIN_FIELD = (1 << 27), }; DEFINE_MTP_CLIENT_FLAGS(MTPDstickerSet) diff --git a/Telegram/SourceFiles/serialize/serialize_document.cpp b/Telegram/SourceFiles/serialize/serialize_document.cpp index 6f489e690..62230b8ab 100644 --- a/Telegram/SourceFiles/serialize/serialize_document.cpp +++ b/Telegram/SourceFiles/serialize/serialize_document.cpp @@ -93,7 +93,7 @@ DocumentData *Document::readFromStreamHelper(int streamAppVersion, QDataStream & if (typeOfSet == StickerSetTypeEmpty) { attributes.push_back(MTP_documentAttributeSticker(MTP_string(alt), MTP_inputStickerSetEmpty())); } else if (info) { - if (info->setId == Stickers::DefaultSetId || info->setId == Stickers::CustomSetId) { + if (info->setId == Stickers::DefaultSetId || info->setId == Stickers::CloudRecentSetId || info->setId == Stickers::CustomSetId) { typeOfSet = StickerSetTypeEmpty; } diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index afb3112e2..aa8ce6175 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -849,16 +849,10 @@ void SettingsInner::keyPressEvent(QKeyEvent *e) { connect(box.get(), SIGNAL(confirmed()), this, SLOT(onSwitchModerateMode())); Ui::showLayer(box.release()); break; - } else if (str == qstr("clearstickers")) { - auto box = std_::make_unique(qsl("Clear frequently used stickers list?")); - connect(box.get(), SIGNAL(confirmed()), this, SLOT(onClearStickers())); - Ui::showLayer(box.release()); - break; } else if ( qsl("debugmode").startsWith(str) || qsl("testmode").startsWith(str) || qsl("loadlang").startsWith(str) || - qsl("clearstickers").startsWith(str) || qsl("moderate").startsWith(str) || qsl("debugfiles").startsWith(str) || qsl("workmode").startsWith(str) || @@ -1267,24 +1261,6 @@ void SettingsInner::onShowSessions() { Ui::showLayer(box); } -void SettingsInner::onClearStickers() { - auto &recent(cGetRecentStickers()); - if (!recent.isEmpty()) { - recent.clear(); - Local::writeUserSettings(); - } - auto &sets(Global::RefStickerSets()); - auto it = sets.find(Stickers::CustomSetId); - if (it != sets.cend()) { - sets.erase(it); - Local::writeStickers(); - } - if (auto m = App::main()) { - emit m->stickersUpdated(); - } - Ui::hideLayer(); -} - void SettingsInner::onSwitchModerateMode() { Global::SetModerateModeEnabled(!Global::ModerateModeEnabled()); Local::writeUserSettings(); diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h index d88df93c8..4d125b4a6 100644 --- a/Telegram/SourceFiles/settingswidget.h +++ b/Telegram/SourceFiles/settingswidget.h @@ -187,7 +187,6 @@ public slots: void onUpdateLocalStorage(); private slots: - void onClearStickers(); void onSwitchModerateMode(); void onAskQuestion();