Allow setting group stickers set.

This commit is contained in:
John Preston 2017-08-05 12:48:21 +02:00
parent ab35829358
commit f04b25ea26
16 changed files with 140 additions and 87 deletions

View File

@ -920,6 +920,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_stickers_count#one" = "{count} sticker";
"lng_stickers_count#other" = "{count} stickers";
"lng_stickers_masks_pack" = "This is a pack of mask stickers. You can use them in the photo editor on our mobile apps.";
"lng_stickers_group_set" = "Group sticker set";
"lng_stickers_remove_group_set" = "Remove group sticker set?";
"lng_in_dlg_photo" = "Photo";
"lng_in_dlg_video" = "Video";

View File

@ -927,7 +927,7 @@ void ApiWrap::saveStickerSets(const Stickers::Order &localOrder, const Stickers:
if (writeArchived) Local::writeArchivedStickers();
if (writeCloudRecent) Local::writeRecentStickers();
if (writeFaved) Local::writeFavedStickers();
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
if (_stickerSetDisenableRequests.isEmpty()) {
stickersSaveOrder();
@ -1466,6 +1466,13 @@ void ApiWrap::updateStickers() {
requestSavedGifs(now);
}
void ApiWrap::setGroupStickerSet(gsl::not_null<ChannelData*> megagroup, const MTPInputStickerSet &set) {
Expects(megagroup->mgInfo != nullptr);
megagroup->mgInfo->stickerSet = set;
request(MTPchannels_SetStickers(megagroup->inputChannel, set)).send();
Auth().data().stickersUpdated().notify(true);
}
void ApiWrap::requestStickers(TimeId now) {
if (Global::LastStickersUpdate() != 0 && now < Global::LastStickersUpdate() + kStickersUpdateTimeout) {
return;

View File

@ -70,6 +70,7 @@ public:
void requestStickerSets();
void saveStickerSets(const Stickers::Order &localOrder, const Stickers::Order &localRemoved);
void updateStickers();
void setGroupStickerSet(gsl::not_null<ChannelData*> megagroup, const MTPInputStickerSet &set);
void joinChannel(ChannelData *channel);
void leaveChannel(ChannelData *channel);

View File

@ -55,6 +55,9 @@ public:
base::Observable<void> &moreChatsLoaded() {
return _moreChatsLoaded;
}
base::Observable<void> &stickersUpdated() {
return _stickersUpdated;
}
base::Observable<void> &savedGifsUpdated() {
return _savedGifsUpdated;
}
@ -147,6 +150,7 @@ private:
base::Variable<bool> _contactsLoaded = { false };
base::Variable<bool> _allChatsLoaded = { false };
base::Observable<void> _moreChatsLoaded;
base::Observable<void> _stickersUpdated;
base::Observable<void> _savedGifsUpdated;
base::Observable<gsl::not_null<History*>> _historyCleared;
base::Observable<gsl::not_null<const HistoryItem*>> _repaintLogEntry;

View File

@ -49,7 +49,7 @@ void StickerSetBox::prepare() {
setTitle(langFactory(lng_contacts_loading));
_inner = setInnerWidget(object_ptr<Inner>(this, _set), st::stickersScroll);
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
subscribe(Auth().data().stickersUpdated(), [this] { updateButtons(); });
setDimensions(st::boxWideWidth, st::stickersMaxHeight);
@ -57,8 +57,6 @@ void StickerSetBox::prepare() {
connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons()));
connect(_inner, SIGNAL(installed(uint64)), this, SLOT(onInstalled(uint64)));
onStickersUpdated();
}
void StickerSetBox::onInstalled(uint64 setId) {
@ -66,10 +64,6 @@ void StickerSetBox::onInstalled(uint64 setId) {
closeBox();
}
void StickerSetBox::onStickersUpdated() {
updateButtons();
}
void StickerSetBox::onAddStickers() {
_inner->install();
}
@ -254,7 +248,7 @@ void StickerSetBox::Inner::installDone(const MTPmessages_StickerSetInstallResult
Local::writeArchivedStickers();
}
Local::writeInstalledStickers();
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
emit installed(_setId);
}

View File

@ -44,7 +44,6 @@ protected:
void resizeEvent(QResizeEvent *e) override;
private slots:
void onStickersUpdated();
void onAddStickers();
void onShareStickers();
void onUpdateButtons();

View File

@ -152,6 +152,12 @@ StickersBox::StickersBox(QWidget*, const Stickers::Order &archivedIds)
, _about(st::boxLabelStyle, lang(lng_stickers_packs_archived), _defaultOptions, _aboutWidth) {
}
StickersBox::StickersBox(QWidget*, gsl::not_null<ChannelData*> megagroup)
: _section(Section::Installed)
, _installed(0, this, megagroup)
, _megagroupSet(megagroup) {
}
void StickersBox::getArchivedDone(uint64 offsetId, const MTPmessages_ArchivedStickers &result) {
_archivedRequestId = 0;
_archivedLoaded = true;
@ -226,16 +232,20 @@ void StickersBox::getArchivedDone(uint64 offsetId, const MTPmessages_ArchivedSti
void StickersBox::prepare() {
if (_section == Section::Installed) {
Local::readArchivedStickers();
if (_tabs) {
Local::readArchivedStickers();
} else {
setTitle(langFactory(lng_stickers_group_set));
}
} else if (_section == Section::Archived) {
requestArchivedSets();
} else if (_section == Section::ArchivedPart) {
setTitle(langFactory(lng_stickers_archived));
}
if (Global::ArchivedStickerSetsOrder().isEmpty()) {
preloadArchivedSets();
}
if (_tabs) {
if (Global::ArchivedStickerSetsOrder().isEmpty()) {
preloadArchivedSets();
}
setNoContentMargin(true);
_tabs->setSectionActivatedCallback([this] {
switchTab();
@ -244,13 +254,15 @@ void StickersBox::prepare() {
}
if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide();
if (_featured.widget() && _section != Section::Featured) _featured.widget()->hide();
if (_section != Section::Archived && _section != Section::ArchivedPart) _archived.widget()->hide();
if (_archived.widget() && _section != Section::Archived && _section != Section::ArchivedPart) _archived.widget()->hide();
if (_featured.widget()) {
_featured.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); });
}
_archived.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); });
_archived.widget()->setLoadMoreCallback([this] { loadMoreArchived(); });
if (_archived.widget()) {
_archived.widget()->setInstallSetCallback([this](uint64 setId) { installSet(setId); });
_archived.widget()->setLoadMoreCallback([this] { loadMoreArchived(); });
}
addButton(langFactory(lng_about_done), [this] { closeBox(); });
@ -268,7 +280,7 @@ void StickersBox::prepare() {
setInnerWidget(_tab->takeWidget(), getTopSkip());
setDimensions(st::boxWideWidth, (_section == Section::ArchivedPart) ? st::sessionsHeight : st::boxMaxListHeight);
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
subscribe(Auth().data().stickersUpdated(), [this] { handleStickersUpdated(); });
Auth().api().updateStickers();
if (_installed.widget()) {
@ -511,10 +523,10 @@ void StickersBox::resizeEvent(QResizeEvent *e) {
}
if (_installed.widget()) _installed.widget()->resize(width(), _installed.widget()->height());
if (_featured.widget()) _featured.widget()->resize(width(), _featured.widget()->height());
_archived.widget()->resize(width(), _archived.widget()->height());
if (_archived.widget()) _archived.widget()->resize(width(), _archived.widget()->height());
}
void StickersBox::onStickersUpdated() {
void StickersBox::handleStickersUpdated() {
if (_section == Section::Installed || _section == Section::Featured) {
rebuildList();
} else {
@ -582,6 +594,15 @@ StickersBox::Inner::Inner(QWidget *parent, const Stickers::Order &archivedIds) :
setup();
}
StickersBox::Inner::Inner(QWidget *parent, gsl::not_null<ChannelData*> megagroup) : TWidget(parent)
, _section(StickersBox::Section::Installed)
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
, _a_shifting(animation(this, &Inner::step_shifting))
, _itemsTop(st::membersMarginTop)
, _megagroupSet(megagroup) {
setup();
}
void StickersBox::Inner::setup() {
subscribe(Auth().downloaderTaskFinished(), [this] {
update();
@ -667,10 +688,10 @@ void StickersBox::Inner::paintRow(Painter &p, int index, TimeMs ms) {
p.setOpacity(1. - current);
paintFakeButton(p, index, ms);
p.setOpacity(1.);
} else {
} else if (!_megagroupSet) {
paintFakeButton(p, index, ms);
}
} else {
} else if (!_megagroupSet) {
paintFakeButton(p, index, ms);
}
@ -680,7 +701,7 @@ void StickersBox::Inner::paintRow(Painter &p, int index, TimeMs ms) {
auto stickerx = st::contactsPadding.left();
if (_section == Section::Installed) {
if (!_megagroupSet && _section == Section::Installed) {
stickerx += st::stickersReorderIcon.width() + st::stickersReorderSkip;
if (!s->isRecentSet()) {
st::stickersReorderIcon.paint(p, st::contactsPadding.left(), (_rowHeight - st::stickersReorderIcon.height()) / 2, width());
@ -889,14 +910,14 @@ void StickersBox::Inner::onUpdateSelected() {
selected = floorclamp(local.y() - _itemsTop, _rowHeight, 0, _rows.size() - 1);
local.setY(local.y() - _itemsTop - selected * _rowHeight);
auto set = _rows[selected];
if (_section == Section::Installed || !set->installed || set->archived || set->removed) {
if (!_megagroupSet && (_section == Section::Installed || !set->installed || set->archived || set->removed)) {
auto removeButton = (_section == Section::Installed && !set->removed);
auto rect = myrtlrect(relativeButtonRect(removeButton));
actionSel = rect.contains(local) ? selected : -1;
} else {
actionSel = -1;
}
if (_section == Section::Installed && !set->isRecentSet()) {
if (!_megagroupSet && _section == Section::Installed && !set->isRecentSet()) {
auto dragAreaWidth = st::contactsPadding.left() + st::stickersReorderIcon.width() + st::stickersReorderSkip;
auto dragArea = myrtlrect(0, 0, dragAreaWidth, _rowHeight);
inDragArea = dragArea.contains(local);
@ -905,7 +926,7 @@ void StickersBox::Inner::onUpdateSelected() {
selected = -1;
}
if (_selected != selected) {
if (_section != Section::Installed && ((_selected >= 0 || _pressed >= 0) != (selected >= 0 || _pressed >= 0))) {
if ((_megagroupSet || _section != Section::Installed) && ((_selected >= 0 || _pressed >= 0) != (selected >= 0 || _pressed >= 0))) {
if (!inDragArea) {
setCursor((selected >= 0 || _pressed >= 0) ? style::cur_pointer : style::cur_default);
}
@ -962,7 +983,13 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
auto it = sets.find(row->id);
if (it != sets.cend()) {
_selected = -1;
Ui::show(Box<StickerSetBox>(Stickers::inputSetId(*it)), KeepOtherLayers);
if (_megagroupSet) {
Auth().api().setGroupStickerSet(_megagroupSet, Stickers::inputSetId(*it));
Ui::hideLayer();
App::main()->onStickersInstalled(Stickers::MegagroupSetId);
} else {
Ui::show(Box<StickerSetBox>(Stickers::inputSetId(*it)), KeepOtherLayers);
}
}
}
}
@ -1082,7 +1109,7 @@ void StickersBox::Inner::rebuild() {
_animStartTimes.reserve(order.size() + 1);
auto &sets = Global::StickerSets();
if (_section == Section::Installed) {
if (!_megagroupSet && _section == Section::Installed) {
auto cloudIt = sets.constFind(Stickers::CloudRecentSetId);
if (cloudIt != sets.cend() && !cloudIt->stickers.isEmpty()) {
rebuildAppendSet(cloudIt.value(), maxNameWidth);

View File

@ -36,8 +36,6 @@ class SlideAnimation;
} // namespace Ui
class StickersBox : public BoxContent, public RPCSender {
Q_OBJECT
public:
enum class Section {
Installed,
@ -47,6 +45,7 @@ public:
};
StickersBox(QWidget*, Section section);
StickersBox(QWidget*, const Stickers::Order &archivedIds);
StickersBox(QWidget*, gsl::not_null<ChannelData*> megagroup);
void closeHook() override;
@ -58,9 +57,6 @@ protected:
void resizeEvent(QResizeEvent *e) override;
void paintEvent(QPaintEvent *e) override;
private slots:
void onStickersUpdated();
private:
class Inner;
class Tab {
@ -93,6 +89,7 @@ private:
};
void handleStickersUpdated();
void refreshTabs();
void rebuildList(Tab *tab = nullptr);
void updateTabsGeometry();
@ -123,6 +120,8 @@ private:
Tab _archived;
Tab *_tab = nullptr;
ChannelData *_megagroupSet = nullptr;
std::unique_ptr<Ui::SlideAnimation> _slideAnimation;
object_ptr<BoxLayerTitleShadow> _titleShadow = { nullptr };
@ -150,6 +149,7 @@ public:
using Section = StickersBox::Section;
Inner(QWidget *parent, Section section);
Inner(QWidget *parent, const Stickers::Order &archivedIds);
Inner(QWidget *parent, gsl::not_null<ChannelData*> megagroup);
void rebuild();
void updateSize();
@ -289,5 +289,6 @@ private:
int _above = -1;
int _scrollbar = 0;
ChannelData *_megagroupSet = nullptr;
};

View File

@ -88,7 +88,7 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) {
Ui::Toast::Show(toast);
// Ui::show(Box<StickersBox>(archived), KeepOtherLayers);
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
// For testing: Just apply random subset or your sticker sets as archived.
@ -148,7 +148,7 @@ void InstallLocally(uint64 setId) {
Local::writeArchivedStickers();
}
}
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
void UndoInstallLocally(uint64 setId) {
@ -167,7 +167,7 @@ void UndoInstallLocally(uint64 setId) {
}
Local::writeInstalledStickers();
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
Ui::show(Box<InformBox>(lang(lng_stickers_not_found)), KeepOtherLayers);
}
@ -254,7 +254,7 @@ void SetIsFaved(gsl::not_null<DocumentData*> document, const std::vector<gsl::no
}
}
Local::writeFavedStickers();
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
App::main()->onStickersInstalled(FavedSetId);
}
@ -284,7 +284,7 @@ void SetIsNotFaved(gsl::not_null<DocumentData*> document) {
sets.erase(it);
}
Local::writeFavedStickers();
emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
void SetFaved(gsl::not_null<DocumentData*> document, bool faved) {
@ -356,7 +356,7 @@ void SetsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
LOG(("API Error: received stickers hash %1 while counted hash is %2").arg(hash).arg(Local::countStickersHash()));
}
if (App::main()) emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
void SetPackAndEmoji(Set &set, StickerPack &&pack, const QVector<MTPStickerPack> &packs) {
@ -457,7 +457,7 @@ void SpecialSetReceived(uint64 setId, const QString &setTitle, const QVector<MTP
default: Unexpected("setId in SpecialSetReceived()");
}
if (App::main()) emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVector<MTPlong> &unread, int32 hash) {
@ -560,7 +560,7 @@ void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVect
Local::writeFeaturedStickers();
if (App::main()) emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
void GifsReceived(const QVector<MTPDocument> &items, int32 hash) {
@ -772,7 +772,7 @@ Set *FeedSetFull(const MTPmessages_StickerSet &data) {
}
}
if (App::main()) emit App::main()->stickersUpdated();
Auth().data().stickersUpdated().notify(true);
return set;
}
@ -811,8 +811,8 @@ void FeaturedReader::readSets() {
if (!wrappedIds.empty()) {
request(MTPmessages_ReadFeaturedStickers(MTP_vector<MTPlong>(wrappedIds))).done([](const MTPBool &result) {
Local::writeFeaturedStickers();
if (auto main = App::main()) {
emit main->stickersUpdated();
if (AuthSession::Exists()) {
Auth().data().stickersUpdated().notify(true);
}
}).send();

View File

@ -517,7 +517,7 @@ bool StickersListWidget::enumerateSections(Callback callback) const {
info.section = i;
info.count = set.pack.size();
info.rowsTop = info.top + (setHasTitle(set) ? st::emojiPanHeader : st::stickerPanPadding);
if (set.id == Stickers::MegagroupEmptySetId) {
if (set.id == Stickers::MegagroupSetId && !info.count) {
info.rowsCount = 0;
info.rowsBottom = info.rowsTop + _megagroupSetButtonRect.y() + _megagroupSetButtonRect.height() + st::stickerGroupCategoryAddMargin.bottom();
} else {
@ -761,21 +761,22 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
p.drawTextLeft(st::emojiPanHeaderLeft - st::buttonRadius, info.top + st::emojiPanHeaderTop, width(), titleText, titleWidth);
}
if (clip.top() + clip.height() > info.rowsTop) {
if (set.id == Stickers::MegagroupEmptySetId) {
if (set.id == Stickers::MegagroupSetId && set.pack.empty()) {
auto buttonSelected = (base::get_if<OverGroupAdd>(&_selected) != nullptr);
paintMegagroupEmptySet(p, info.rowsTop, buttonSelected, ms);
}
auto special = (set.flags & MTPDstickerSet::Flag::f_official) != 0;
auto fromRow = floorclamp(clip.y() - info.rowsTop, st::stickerPanSize.height(), 0, info.rowsCount);
auto toRow = ceilclamp(clip.y() + clip.height() - info.rowsTop, st::stickerPanSize.height(), 0, info.rowsCount);
for (int i = fromRow; i < toRow; ++i) {
for (int j = fromColumn; j < toColumn; ++j) {
int index = i * kStickersPanelPerRow + j;
if (index >= info.count) break;
} else {
auto special = (set.flags & MTPDstickerSet::Flag::f_official) != 0;
auto fromRow = floorclamp(clip.y() - info.rowsTop, st::stickerPanSize.height(), 0, info.rowsCount);
auto toRow = ceilclamp(clip.y() + clip.height() - info.rowsTop, st::stickerPanSize.height(), 0, info.rowsCount);
for (int i = fromRow; i < toRow; ++i) {
for (int j = fromColumn; j < toColumn; ++j) {
int index = i * kStickersPanelPerRow + j;
if (index >= info.count) break;
auto selected = selectedSticker ? (selectedSticker->section == info.section && selectedSticker->index == index) : false;
auto deleteSelected = selected && selectedSticker->overDelete;
paintSticker(p, set, info.rowsTop, index, selected, deleteSelected);
auto selected = selectedSticker ? (selectedSticker->section == info.section && selectedSticker->index == index) : false;
auto deleteSelected = selected && selectedSticker->overDelete;
paintSticker(p, set, info.rowsTop, index, selected, deleteSelected);
}
}
}
}
@ -874,9 +875,9 @@ bool StickersListWidget::hasRemoveButton(int index) const {
if (!(flags & MTPDstickerSet_ClientFlag::f_special)) {
return true;
}
if (set.megagroupSet) {
if (set.id == Stickers::MegagroupSetId) {
t_assert(_megagroupSet != nullptr);
return (set.id == Stickers::MegagroupEmptySetId) ? (index + 1 != _mySets.size()) : _megagroupSet->canEditStickers();
return set.pack.empty() ? (index + 1 != _mySets.size()) : _megagroupSet->canEditStickers();
}
return false;
}
@ -939,7 +940,7 @@ QRect StickersListWidget::megagroupSetButtonRectFinal() const {
auto result = QRect();
if (_section == Section::Stickers) {
enumerateSections([this, &result](const SectionInfo &info) {
if (_mySets[info.section].id == Stickers::MegagroupEmptySetId) {
if (_mySets[info.section].id == Stickers::MegagroupSetId) {
result = _megagroupSetButtonRect.translated(0, info.rowsTop);
return false;
}
@ -1013,11 +1014,13 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
t_assert(button->section >= 0 && button->section < sets.size());
if (_section == Section::Featured) {
installSet(sets[button->section].id);
} else if (sets[button->section].id == Stickers::MegagroupSetId) {
removeMegagroupSet(sets[button->section].pack.empty());
} else {
removeSet(sets[button->section].id);
}
} else if (base::get_if<OverGroupAdd>(&pressed)) {
Ui::show(Box<InformBox>("TODO"));
Ui::show(Box<StickersBox>(_megagroupSet));
}
}
}
@ -1291,16 +1294,16 @@ void StickersListWidget::refreshMegagroupStickers() {
}
if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetEmpty) {
if (_megagroupSet->canEditStickers()) {
_mySets.push_back(Set(Stickers::MegagroupEmptySetId, qFlags(MTPDstickerSet_ClientFlag::f_special), lang(lng_group_stickers), 0));
_mySets.back().megagroupSet = true;
_mySets.push_back(Set(Stickers::MegagroupSetId, qFlags(MTPDstickerSet_ClientFlag::f_special), lang(lng_group_stickers), 0));
}
return;
}
if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) {
auto &set = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID();
appendSet(_mySets, set.vid.v);
if (_mySets.back().id == set.vid.v) {
_mySets.back().megagroupSet = true;
auto &sets = Global::StickerSets();
auto it = sets.constFind(set.vid.v);
if (it != sets.cend()) {
_mySets.push_back(Set(Stickers::MegagroupSetId, qFlags(MTPDstickerSet_ClientFlag::f_special), lang(lng_group_stickers), it->stickers.size() + 1, it->stickers));
return;
}
}
@ -1328,8 +1331,8 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
icons.push_back(StickerIcon(Stickers::FavedSetId));
}
for (auto l = _mySets.size(); i != l; ++i) {
if (_mySets[i].megagroupSet) {
icons.push_back(StickerIcon(Stickers::MegagroupEmptySetId));
if (_mySets[i].id == Stickers::MegagroupSetId) {
icons.push_back(StickerIcon(Stickers::MegagroupSetId));
icons.back().megagroup = _megagroupSet;
continue;
}
@ -1407,7 +1410,7 @@ void StickersListWidget::updateSelected() {
} else if (p.y() >= info.rowsTop && p.y() < info.rowsBottom && sx >= 0) {
auto yOffset = p.y() - info.rowsTop;
auto &set = sets[section];
if (set.id == Stickers::MegagroupEmptySetId) {
if (set.id == Stickers::MegagroupSetId && set.pack.empty()) {
if (_megagroupSetButtonRect.contains(stickersLeft() + sx, yOffset)) {
newSelected = OverGroupAdd {};
}
@ -1563,7 +1566,7 @@ void StickersListWidget::showMegagroupSet(ChannelData *megagroup) {
}
}
void StickersListWidget::displaySet(quint64 setId) {
void StickersListWidget::displaySet(uint64 setId) {
auto &sets = Global::StickerSets();
auto it = sets.constFind(setId);
if (it != sets.cend()) {
@ -1576,7 +1579,7 @@ void StickersListWidget::displaySet(quint64 setId) {
}
}
void StickersListWidget::installSet(quint64 setId) {
void StickersListWidget::installSet(uint64 setId) {
auto &sets = Global::StickerSets();
auto it = sets.constFind(setId);
if (it != sets.cend()) {
@ -1594,7 +1597,26 @@ void StickersListWidget::installSet(quint64 setId) {
}
}
void StickersListWidget::removeSet(quint64 setId) {
void StickersListWidget::removeMegagroupSet(bool empty) {
if (empty) {
return; // TODO
}
_removingSetId = Stickers::MegagroupSetId;
Ui::show(Box<ConfirmBox>(lang(lng_stickers_remove_group_set), base::lambda_guarded(this, [this, group = _megagroupSet] {
Expects(group->mgInfo != nullptr);
if (group->mgInfo->stickerSet.type() != mtpc_inputStickerSetEmpty) {
Auth().api().setGroupStickerSet(group, MTP_inputStickerSetEmpty());
}
Ui::hideLayer();
_removingSetId = 0;
emit checkForHide();
}), base::lambda_guarded(this, [this] {
_removingSetId = 0;
emit checkForHide();
})));
}
void StickersListWidget::removeSet(uint64 setId) {
auto &sets = Global::StickerSets();
auto it = sets.constFind(setId);
if (it != sets.cend()) {

View File

@ -134,7 +134,6 @@ private:
Set(uint64 id, MTPDstickerSet::Flags flags, const QString &title, int32 hoversSize, const StickerPack &pack = StickerPack()) : id(id), flags(flags), title(title), pack(pack) {
}
uint64 id;
bool megagroupSet = false;
MTPDstickerSet::Flags flags;
QString title;
StickerPack pack;
@ -147,9 +146,10 @@ private:
SectionInfo sectionInfo(int section) const;
SectionInfo sectionInfoByOffset(int yOffset) const;
void displaySet(quint64 setId);
void installSet(quint64 setId);
void removeSet(quint64 setId);
void displaySet(uint64 setId);
void installSet(uint64 setId);
void removeMegagroupSet(bool empty);
void removeSet(uint64 setId);
bool setHasTitle(const Set &set) const;
bool stickerHasDeleteButton(const Set &set, int index) const;

View File

@ -251,7 +251,7 @@ constexpr auto NoneSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel, s
constexpr auto CloudRecentSetId = 0xFFFFFFFFFFFFFFFCULL; // for cloud-stored recent stickers
constexpr auto FeaturedSetId = 0xFFFFFFFFFFFFFFFBULL; // for emoji/stickers panel, should not appear in Sets
constexpr auto FavedSetId = 0xFFFFFFFFFFFFFFFAULL; // for cloud-stored faved stickers
constexpr auto MegagroupEmptySetId = 0xFFFFFFFFFFFFFFEFULL; // for setting up megagroup sticker set
constexpr auto MegagroupSetId = 0xFFFFFFFFFFFFFFEFULL; // for setting up megagroup sticker set
struct Set {
Set(uint64 id, uint64 access, const QString &title, const QString &shortName, int32 count, int32 hash, MTPDstickerSet::Flags flags)
: id(id)

View File

@ -921,7 +921,10 @@ int HistoryWidget::itemTopForHighlight(gsl::not_null<HistoryItem*> item) const {
}
void HistoryWidget::start() {
connect(App::main(), SIGNAL(stickersUpdated()), this, SLOT(onStickersUpdated()));
subscribe(Auth().data().stickersUpdated(), [this] {
_tabbedSelector->refreshStickers();
updateStickersByEmoji();
});
updateRecentStickers();
Auth().data().savedGifsUpdated().notify();
subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) {
@ -929,11 +932,6 @@ void HistoryWidget::start() {
});
}
void HistoryWidget::onStickersUpdated() {
_tabbedSelector->refreshStickers();
updateStickersByEmoji();
}
void HistoryWidget::onMentionInsert(UserData *user) {
QString replacement, entityTag;
if (user->username.isEmpty()) {

View File

@ -425,7 +425,6 @@ public slots:
void onCmdStart();
void activate();
void onStickersUpdated();
void onTextChange();
void onFieldTabbed();

View File

@ -5285,7 +5285,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
}
Local::writeInstalledStickers();
if (writeArchived) Local::writeArchivedStickers();
emit stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
}
}
@ -5309,7 +5309,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
} else {
Global::SetStickerSetsOrder(result);
Local::writeInstalledStickers();
emit stickersUpdated();
Auth().data().stickersUpdated().notify(true);
}
}
} break;

View File

@ -411,7 +411,6 @@ signals:
void peerPhotoChanged(PeerData *peer);
void dialogRowReplaced(Dialogs::Row *oldRow, Dialogs::Row *newRow);
void dialogsUpdated();
void stickersUpdated();
public slots:
void webPagesOrGamesUpdate();