예제 #1
0
void StickerSetInner::installDone(const MTPBool &result) {
	StickerSets &sets(cRefStickerSets());

	sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName)).value().stickers = _pack;
	int32 index = cStickerSetsOrder().indexOf(_setId);
	if (index > 0) {
		cRefStickerSetsOrder().removeAt(index);
		cRefStickerSetsOrder().push_front(_setId);
	} else if (index < 0) {
		cRefStickerSetsOrder().push_front(_setId);
	}

	StickerSets::iterator custom = sets.find(CustomStickerSetId);
	if (custom != sets.cend()) {
		for (int32 i = 0, l = _pack.size(); i < l; ++i) {
			custom->stickers.removeOne(_pack.at(i));
		}
		if (custom->stickers.isEmpty()) {
			sets.erase(custom);
		}
	}
	cSetStickersHash(QByteArray());
	Local::writeStickers();
	emit installed(_setId);
	App::wnd()->hideLayer();
}
예제 #2
0
void StickerSetInner::installDone(const MTPBool &result) {
	StickerSets &sets(cRefStickerSets());

	sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags)).value().stickers = _pack;

	int32 insertAtIndex = 0;
	StickerSetsOrder &order(cRefStickerSetsOrder());
	for (int32 s = order.size(); insertAtIndex < s; ++insertAtIndex) {
		StickerSets::const_iterator i = sets.constFind(order.at(insertAtIndex));
		if (i == sets.cend() || !(i->flags & MTPDstickerSet_flag_official)) {
			break;
		}
	}
	int32 currentIndex = cStickerSetsOrder().indexOf(_setId);
	if (currentIndex != insertAtIndex) {
		if (currentIndex > 0) {
			order.removeAt(currentIndex);
			if (currentIndex < insertAtIndex) {
				--insertAtIndex;
			}
		}
		order.insert(insertAtIndex, _setId);
	}

	StickerSets::iterator custom = sets.find(CustomStickerSetId);
	if (custom != sets.cend()) {
		for (int32 i = 0, l = _pack.size(); i < l; ++i) {
			custom->stickers.removeOne(_pack.at(i));
		}
		if (custom->stickers.isEmpty()) {
			sets.erase(custom);
		}
	}
	cSetStickersHash(QByteArray());
	Local::writeStickers();
	emit installed(_setId);
	App::wnd()->hideLayer();
}