dev version 0.9.19 sending stickers by emoji

This commit is contained in:
John Preston 2016-01-09 20:51:42 +08:00
parent a72a31e722
commit b13579c7d9
19 changed files with 184 additions and 143 deletions

View File

@ -672,9 +672,9 @@ void ApiWrap::scheduleStickerSetRequest(uint64 setId, uint64 access) {
void ApiWrap::requestStickerSets() { void ApiWrap::requestStickerSets() {
for (QMap<uint64, QPair<uint64, mtpRequestId> >::iterator i = _stickerSetRequests.begin(), j = i, e = _stickerSetRequests.end(); i != e; i = j) { for (QMap<uint64, QPair<uint64, mtpRequestId> >::iterator i = _stickerSetRequests.begin(), j = i, e = _stickerSetRequests.end(); i != e; i = j) {
++j;
if (i.value().second) continue; if (i.value().second) continue;
++j;
int32 wait = (j == e) ? 0 : 10; int32 wait = (j == e) ? 0 : 10;
i.value().second = MTP::send(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first))), rpcDone(&ApiWrap::gotStickerSet, i.key()), rpcFail(&ApiWrap::gotStickerSetFail, i.key()), 0, wait); i.value().second = MTP::send(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first))), rpcDone(&ApiWrap::gotStickerSet, i.key()), rpcFail(&ApiWrap::gotStickerSetFail, i.key()), 0, wait);
} }
@ -685,7 +685,6 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
if (result.type() != mtpc_messages_stickerSet) return; if (result.type() != mtpc_messages_stickerSet) return;
const MTPDmessages_stickerSet &d(result.c_messages_stickerSet()); const MTPDmessages_stickerSet &d(result.c_messages_stickerSet());
const QVector<MTPStickerPack> &v(d.vpacks.c_vector().v);
if (d.vset.type() != mtpc_stickerSet) return; if (d.vset.type() != mtpc_stickerSet) return;
const MTPDstickerSet &s(d.vset.c_stickerSet()); const MTPDstickerSet &s(d.vset.c_stickerSet());
@ -733,14 +732,31 @@ void ApiWrap::gotStickerSet(uint64 setId, const MTPmessages_StickerSet &result)
} }
} }
Global::StickersByEmoji_RemovePack(it->stickers);
if (pack.isEmpty()) { if (pack.isEmpty()) {
int32 removeIndex = cStickerSetsOrder().indexOf(setId); int32 removeIndex = cStickerSetsOrder().indexOf(setId);
if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex); if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex);
sets.erase(it); sets.erase(it);
} else { } else {
it->stickers = pack; it->stickers = pack;
Global::StickersByEmoji_AddPack(it->stickers); it->emoji.clear();
const QVector<MTPStickerPack> &v(d.vpacks.c_vector().v);
for (int32 i = 0, l = v.size(); i < l; ++i) {
if (v.at(i).type() != mtpc_stickerPack) continue;
const MTPDstickerPack &pack(v.at(i).c_stickerPack());
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
DocumentData *doc = App::document(stickers.at(j).v);
if (!doc || !doc->sticker()) continue;
p.push_back(doc);
}
it->emoji.insert(e, p);
}
}
} }
if (writeRecent) { if (writeRecent) {

View File

@ -1969,7 +1969,6 @@ namespace App {
if (api()) api()->clearWebPageRequests(); if (api()) api()->clearWebPageRequests();
cSetRecentStickers(RecentStickerPack()); cSetRecentStickers(RecentStickerPack());
cSetStickerSets(StickerSets()); cSetStickerSets(StickerSets());
Global::SetStickersByEmoji(StickersByEmojiMap());
cSetStickerSetsOrder(StickerSetsOrder()); cSetStickerSetsOrder(StickerSetsOrder());
cSetLastStickersUpdate(0); cSetLastStickersUpdate(0);
cSetSavedGifs(SavedGifs()); cSetSavedGifs(SavedGifs());

View File

@ -705,9 +705,8 @@ void Application::checkMapVersion() {
if (Local::oldMapVersion() < AppVersion) { if (Local::oldMapVersion() < AppVersion) {
if (Local::oldMapVersion()) { if (Local::oldMapVersion()) {
QString versionFeatures; QString versionFeatures;
if (cDevVersion() && Local::oldMapVersion() < 9016) { if (cDevVersion() && Local::oldMapVersion() < 9019) {
// versionFeatures = QString::fromUtf8("\xe2\x80\x94 Sticker management: manually rearrange your sticker packs, pack order is now synced across all your devices\n\xe2\x80\x94 Click and hold on a sticker to preview it before sending\n\xe2\x80\x94 New context menu for chats in chats list\n\xe2\x80\x94 Support for all existing emoji");// .replace('@', qsl("@") + QChar(0x200D)); versionFeatures = QString::fromUtf8("\xe2\x80\x94 Choose an emoticon and see the suggested stickers\n\xe2\x80\x94 Bug fixes in minor improvements");// .replace('@', qsl("@") + QChar(0x200D));
versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed();
} else if (Local::oldMapVersion() < 9016) { } else if (Local::oldMapVersion() < 9016) {
versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed(); versionFeatures = lng_new_version_text(lt_gifs_link, qsl("https://telegram.org/blog/gif-revolution"), lt_bots_link, qsl("https://telegram.org/blog/inline-bots")).trimmed();
} else { } else {

View File

@ -43,6 +43,7 @@ _input(set), _installRequest(0) {
void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) { void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.clear(); _pack.clear();
_emoji.clear();
if (set.type() == mtpc_messages_stickerSet) { if (set.type() == mtpc_messages_stickerSet) {
const MTPDmessages_stickerSet &d(set.c_messages_stickerSet()); const MTPDmessages_stickerSet &d(set.c_messages_stickerSet());
const QVector<MTPDocument> &v(d.vdocuments.c_vector().v); const QVector<MTPDocument> &v(d.vdocuments.c_vector().v);
@ -53,6 +54,23 @@ void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.push_back(doc); _pack.push_back(doc);
} }
const QVector<MTPStickerPack> &packs(d.vpacks.c_vector().v);
for (int32 i = 0, l = packs.size(); i < l; ++i) {
if (packs.at(i).type() != mtpc_stickerPack) continue;
const MTPDstickerPack &pack(packs.at(i).c_stickerPack());
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
DocumentData *doc = App::document(stickers.at(j).v);
if (!doc || !doc->sticker()) continue;
p.push_back(doc);
}
_emoji.insert(e, p);
}
}
if (d.vset.type() == mtpc_stickerSet) { if (d.vset.type() == mtpc_stickerSet) {
const MTPDstickerSet &s(d.vset.c_stickerSet()); const MTPDstickerSet &s(d.vset.c_stickerSet());
_setTitle = stickerSetTitle(s); _setTitle = stickerSetTitle(s);
@ -91,8 +109,12 @@ void StickerSetInner::installDone(const MTPBool &result) {
StickerSets &sets(cRefStickerSets()); StickerSets &sets(cRefStickerSets());
_setFlags &= ~MTPDstickerSet::flag_disabled; _setFlags &= ~MTPDstickerSet::flag_disabled;
sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags)).value().stickers = _pack; StickerSets::iterator it = sets.find(_setId);
Global::StickersByEmoji_AddPack(_pack); if (it == sets.cend()) {
it = sets.insert(_setId, StickerSet(_setId, _setAccess, _setTitle, _setShortName, _setCount, _setHash, _setFlags));
}
it.value().stickers = _pack;
it.value().emoji = _emoji;
StickerSetsOrder &order(cRefStickerSetsOrder()); StickerSetsOrder &order(cRefStickerSetsOrder());
int32 insertAtIndex = 0, currentIndex = order.indexOf(_setId); int32 insertAtIndex = 0, currentIndex = order.indexOf(_setId);
@ -868,7 +890,6 @@ void StickersBox::onSave() {
if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex); if (removeIndex >= 0) cRefStickerSetsOrder().removeAt(removeIndex);
sets.erase(it); sets.erase(it);
} }
Global::StickersByEmoji_RemovePack(it->stickers);
} }
} }
} }
@ -881,7 +902,6 @@ void StickersBox::onSave() {
MTPInputStickerSet setId = (it->id && it->access) ? MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)) : MTP_inputStickerSetShortName(MTP_string(it->shortName)); MTPInputStickerSet setId = (it->id && it->access) ? MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)) : MTP_inputStickerSetShortName(MTP_string(it->shortName));
_disenableRequests.insert(MTP::send(MTPmessages_InstallStickerSet(setId, MTP_boolFalse()), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType()); _disenableRequests.insert(MTP::send(MTPmessages_InstallStickerSet(setId, MTP_boolFalse()), rpcDone(&StickersBox::disenableDone), rpcFail(&StickersBox::disenableFail), 0, 5), NullType());
it->flags &= ~MTPDstickerSet::flag_disabled; it->flags &= ~MTPDstickerSet::flag_disabled;
Global::StickersByEmoji_AddPack(it->stickers);
} }
order.push_back(reorder.at(i)); order.push_back(reorder.at(i));
} }
@ -890,7 +910,6 @@ void StickersBox::onSave() {
if (it->id == CustomStickerSetId || it->id == RecentStickerSetId || order.contains(it->id)) { if (it->id == CustomStickerSetId || it->id == RecentStickerSetId || order.contains(it->id)) {
++it; ++it;
} else { } else {
Global::StickersByEmoji_RemovePack(it->stickers);
it = sets.erase(it); it = sets.erase(it);
} }
} }

View File

@ -32,7 +32,7 @@ public:
void init(); void init();
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
bool loaded() const; bool loaded() const;
int32 notInstalled() const; int32 notInstalled() const;
bool official() const; bool official() const;
@ -60,6 +60,7 @@ private:
bool installFailed(const RPCError &error); bool installFailed(const RPCError &error);
StickerPack _pack; StickerPack _pack;
StickersByEmojiMap _emoji;
bool _loaded; bool _loaded;
uint64 _setId, _setAccess; uint64 _setId, _setAccess;
QString _title, _setTitle, _setShortName; QString _title, _setTitle, _setShortName;
@ -118,7 +119,7 @@ public:
void mousePressEvent(QMouseEvent *e); void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e); void mouseReleaseEvent(QMouseEvent *e);
void rebuild(); void rebuild();
bool savingStart() { bool savingStart() {
if (_saving) return false; if (_saving) return false;
@ -201,7 +202,7 @@ public:
StickersBox(); StickersBox();
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
void closePressed(); void closePressed();
public slots: public slots:

View File

@ -20,9 +20,9 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
*/ */
#pragma once #pragma once
static const int32 AppVersion = 9018; static const int32 AppVersion = 9019;
static const wchar_t *AppVersionStr = L"0.9.18"; static const wchar_t *AppVersionStr = L"0.9.19";
static const bool DevVersion = false; static const bool DevVersion = true;
//#define BETA_VERSION (9015008ULL) // just comment this line to build public version //#define BETA_VERSION (9015008ULL) // just comment this line to build public version
static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)";

View File

@ -3564,7 +3564,6 @@ void EmojiPan::onRemoveSetSure() {
Ui::hideLayer(); Ui::hideLayer();
StickerSets::iterator it = cRefStickerSets().find(_removingSetId); StickerSets::iterator it = cRefStickerSets().find(_removingSetId);
if (it != cRefStickerSets().cend() && !(it->flags & MTPDstickerSet::flag_official)) { if (it != cRefStickerSets().cend() && !(it->flags & MTPDstickerSet::flag_official)) {
Global::StickersByEmoji_RemovePack(it->stickers);
if (it->id && it->access) { if (it->id && it->access) {
MTP::send(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)))); MTP::send(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access))));
} else if (!it->shortName.isEmpty()) { } else if (!it->shortName.isEmpty()) {
@ -3842,7 +3841,7 @@ void EmojiPan::recountContentMaxHeight() {
updateContentHeight(); updateContentHeight();
} }
MentionsInner::MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows, StickerByEmojiRows *srows) MentionsInner::MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows, StickerPack *srows)
: _parent(parent) : _parent(parent)
, _mrows(mrows) , _mrows(mrows)
, _hrows(hrows) , _hrows(hrows)
@ -4290,7 +4289,7 @@ void MentionsDropdown::showStickers(EmojiPtr emoji) {
bool resetScroll = (_emoji != emoji); bool resetScroll = (_emoji != emoji);
_emoji = emoji; _emoji = emoji;
if (!emoji) { if (!emoji) {
rowsUpdated(_mrows, _hrows, _brows, StickerByEmojiRows(), false); rowsUpdated(_mrows, _hrows, _brows, StickerPack(), false);
return; return;
} }
@ -4312,16 +4311,31 @@ void MentionsDropdown::updateFiltered(bool resetScroll) {
MentionRows mrows; MentionRows mrows;
HashtagRows hrows; HashtagRows hrows;
BotCommandRows brows; BotCommandRows brows;
StickerByEmojiRows srows; StickerPack srows;
if (_emoji) { if (_emoji) {
const StickersByEmojiMap &stickers(Global::StickersByEmoji()); QMap<uint64, uint64> setsToRequest;
StickersByEmojiMap::const_iterator it = stickers.constFind(emojiGetNoColor(_emoji)); StickerSets &sets(cRefStickerSets());
if (it != stickers.cend() && !it->isEmpty()) { const StickerSetsOrder &order(cStickerSetsOrder());
srows.reserve(it->size()); for (int32 i = 0, l = order.size(); i < l; ++i) {
for (StickersByEmojiList::const_iterator i = it->cbegin(), e = it->cend(); i != e; ++i) { StickerSets::iterator it = sets.find(order.at(i));
srows.push_back(i.key()); if (it != sets.cend()) {
if (it->emoji.isEmpty()) {
setsToRequest.insert(it->id, it->access);
it->flags |= MTPDstickerSet_flag_NOT_LOADED;
} else {
StickersByEmojiMap::const_iterator i = it->emoji.constFind(emojiGetNoColor(_emoji));
if (i != it->emoji.cend()) {
srows.append(*i);
}
}
} }
} }
if (!setsToRequest.isEmpty() && App::api()) {
for (QMap<uint64, uint64>::const_iterator i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
App::api()->scheduleStickerSetRequest(i.key(), i.value());
}
App::api()->requestStickerSets();
}
} else if (_filter.at(0) == '@') { } else if (_filter.at(0) == '@') {
if (_chat) { if (_chat) {
mrows.reserve((_addInlineBots ? cRecentInlineBots().size() : 0) + (_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size())); mrows.reserve((_addInlineBots ? cRecentInlineBots().size() : 0) + (_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size()));
@ -4464,7 +4478,7 @@ void MentionsDropdown::updateFiltered(bool resetScroll) {
_inner.setRecentInlineBotsInRows(recentInlineBots); _inner.setRecentInlineBotsInRows(recentInlineBots);
} }
void MentionsDropdown::rowsUpdated(const MentionRows &mrows, const HashtagRows &hrows, const BotCommandRows &brows, const StickerByEmojiRows &srows, bool resetScroll) { void MentionsDropdown::rowsUpdated(const MentionRows &mrows, const HashtagRows &hrows, const BotCommandRows &brows, const StickerPack &srows, bool resetScroll) {
if (mrows.isEmpty() && hrows.isEmpty() && brows.isEmpty() && srows.isEmpty()) { if (mrows.isEmpty() && hrows.isEmpty() && brows.isEmpty() && srows.isEmpty()) {
if (!isHidden()) { if (!isHidden()) {
hideStart(); hideStart();

View File

@ -727,7 +727,6 @@ private:
typedef QList<UserData*> MentionRows; typedef QList<UserData*> MentionRows;
typedef QList<QString> HashtagRows; typedef QList<QString> HashtagRows;
typedef QList<QPair<UserData*, const BotCommand*> > BotCommandRows; typedef QList<QPair<UserData*, const BotCommand*> > BotCommandRows;
typedef QList<DocumentData*> StickerByEmojiRows;
class MentionsDropdown; class MentionsDropdown;
class MentionsInner : public TWidget { class MentionsInner : public TWidget {
@ -735,7 +734,7 @@ class MentionsInner : public TWidget {
public: public:
MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows, StickerByEmojiRows *srows); MentionsInner(MentionsDropdown *parent, MentionRows *mrows, HashtagRows *hrows, BotCommandRows *brows, StickerPack *srows);
void paintEvent(QPaintEvent *e); void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e); void resizeEvent(QResizeEvent *e);
@ -774,7 +773,7 @@ private:
MentionRows *_mrows; MentionRows *_mrows;
HashtagRows *_hrows; HashtagRows *_hrows;
BotCommandRows *_brows; BotCommandRows *_brows;
StickerByEmojiRows *_srows; StickerPack *_srows;
int32 _stickersPerRow, _recentInlineBotsInRows; int32 _stickersPerRow, _recentInlineBotsInRows;
int32 _sel; int32 _sel;
bool _mouseSel; bool _mouseSel;
@ -845,9 +844,9 @@ private:
MentionRows _mrows; MentionRows _mrows;
HashtagRows _hrows; HashtagRows _hrows;
BotCommandRows _brows; BotCommandRows _brows;
StickerByEmojiRows _srows; StickerPack _srows;
void rowsUpdated(const MentionRows &mrows, const HashtagRows &hrows, const BotCommandRows &brows, const StickerByEmojiRows &srows, bool resetScroll); void rowsUpdated(const MentionRows &mrows, const HashtagRows &hrows, const BotCommandRows &brows, const StickerPack &srows, bool resetScroll);
ScrollArea _scroll; ScrollArea _scroll;
MentionsInner _inner; MentionsInner _inner;

View File

@ -179,8 +179,6 @@ namespace Global {
struct Data { struct Data {
uint64 LaunchId; uint64 LaunchId;
StickersByEmojiMap StickersByEmoji;
}; };
Data *_data = 0; Data *_data = 0;
@ -188,6 +186,7 @@ namespace Global {
Initializer::Initializer() { Initializer::Initializer() {
initThirdParty(); initThirdParty();
_data = new Data(); _data = new Data();
memset_rand(&_data->LaunchId, sizeof(_data->LaunchId)); memset_rand(&_data->LaunchId, sizeof(_data->LaunchId));
} }
@ -211,46 +210,4 @@ Type &Ref##Name() { \
DefineGlobalReadOnly(uint64, LaunchId); DefineGlobalReadOnly(uint64, LaunchId);
DefineGlobal(StickersByEmojiMap, StickersByEmoji);
void StickersByEmoji_Add(DocumentData *doc) {
if (StickerData *sticker = doc->sticker()) {
if (EmojiPtr emoji = emojiGetNoColor(emojiFromText(sticker->alt))) {
RefStickersByEmoji()[emoji].insert(doc);
}
}
}
bool StickersByEmoji_Remove(DocumentData *doc) {
if (StickerData *sticker = doc->sticker()) {
if (EmojiPtr emoji = emojiGetNoColor(emojiFromText(sticker->alt))) {
StickersByEmojiMap stickers(RefStickersByEmoji());
StickersByEmojiMap::iterator iList = stickers.find(emoji);
if (iList != stickers.cend()) {
StickersByEmojiList::iterator iEntry = iList->find(doc);
if (iEntry != iList->cend()) {
iList->erase(iEntry);
if (iList->isEmpty()) {
stickers.erase(iList);
}
return true;
}
}
}
}
return false;
}
void StickersByEmoji_AddPack(const StickerPack &pack) {
for (StickerPack::const_iterator i = pack.cbegin(), e = pack.cend(); i != e; ++i) {
StickersByEmoji_Add(*i);
}
}
void StickersByEmoji_RemovePack(const StickerPack &pack) {
for (StickerPack::const_iterator i = pack.cbegin(), e = pack.cend(); i != e; ++i) {
StickersByEmoji_Remove(*i);
}
}
}; };

View File

@ -96,9 +96,6 @@ namespace Notify {
}; };
typedef OrderedSet<DocumentData*> StickersByEmojiList;
typedef QMap<EmojiPtr, StickersByEmojiList> StickersByEmojiMap;
namespace Global { namespace Global {
class Initializer { class Initializer {
@ -114,10 +111,4 @@ namespace Global {
DeclareGlobalReadOnly(uint64, LaunchId); DeclareGlobalReadOnly(uint64, LaunchId);
DeclareGlobal(StickersByEmojiMap, StickersByEmoji);
void StickersByEmoji_Add(DocumentData *doc);
bool StickersByEmoji_Remove(DocumentData *doc);
void StickersByEmoji_AddPack(const StickerPack &pack);
void StickersByEmoji_RemovePack(const StickerPack &pack);
}; };

View File

@ -3164,24 +3164,24 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
for (int32 i = 0, l = d_sets.size(); i != l; ++i) { for (int32 i = 0, l = d_sets.size(); i != l; ++i) {
if (d_sets.at(i).type() == mtpc_stickerSet) { if (d_sets.at(i).type() == mtpc_stickerSet) {
const MTPDstickerSet &set(d_sets.at(i).c_stickerSet()); const MTPDstickerSet &set(d_sets.at(i).c_stickerSet());
StickerSets::iterator i = sets.find(set.vid.v); StickerSets::iterator it = sets.find(set.vid.v);
QString title = stickerSetTitle(set); QString title = stickerSetTitle(set);
if (i == sets.cend()) { if (it == sets.cend()) {
i = sets.insert(set.vid.v, StickerSet(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | MTPDstickerSet_flag_NOT_LOADED)); it = sets.insert(set.vid.v, StickerSet(set.vid.v, set.vaccess_hash.v, title, qs(set.vshort_name), set.vcount.v, set.vhash.v, set.vflags.v | MTPDstickerSet_flag_NOT_LOADED));
} else { } else {
i->access = set.vaccess_hash.v; it->access = set.vaccess_hash.v;
i->title = title; it->title = title;
i->shortName = qs(set.vshort_name); it->shortName = qs(set.vshort_name);
i->flags = set.vflags.v; it->flags = set.vflags.v;
if (i->count != set.vcount.v || i->hash != set.vhash.v) { if (it->count != set.vcount.v || it->hash != set.vhash.v || it->emoji.isEmpty()) {
i->count = set.vcount.v; it->count = set.vcount.v;
i->hash = set.vhash.v; it->hash = set.vhash.v;
i->flags |= MTPDstickerSet_flag_NOT_LOADED; // need to request this set it->flags |= MTPDstickerSet_flag_NOT_LOADED; // need to request this set
} }
} }
if (!(i->flags & MTPDstickerSet::flag_disabled) || (i->flags & MTPDstickerSet::flag_official)) { if (!(it->flags & MTPDstickerSet::flag_disabled) || (it->flags & MTPDstickerSet::flag_official)) {
setsOrder.push_back(set.vid.v); setsOrder.push_back(set.vid.v);
if (i->stickers.isEmpty() || (i->flags & MTPDstickerSet_flag_NOT_LOADED)) { if (it->stickers.isEmpty() || (it->flags & MTPDstickerSet_flag_NOT_LOADED)) {
setsToRequest.insert(set.vid.v, set.vaccess_hash.v); setsToRequest.insert(set.vid.v, set.vaccess_hash.v);
} }
} }
@ -3201,7 +3201,6 @@ void HistoryWidget::stickersGot(const MTPmessages_AllStickers &stickers) {
++i; ++i;
} }
} }
Global::StickersByEmoji_RemovePack(it->stickers);
it = sets.erase(it); it = sets.erase(it);
} }
} }

View File

@ -2843,6 +2843,16 @@ namespace Local {
} }
_writeStorageImageLocation(stream, doc->sticker()->loc); _writeStorageImageLocation(stream, doc->sticker()->loc);
} }
if (AppVersion > 9018) {
stream << qint32(it->emoji.size());
for (StickersByEmojiMap::const_iterator j = it->emoji.cbegin(), e = it->emoji.cend(); j != e; ++j) {
stream << emojiString(j.key()) << qint32(j->size());
for (int32 k = 0, l = j->size(); k < l; ++k) {
stream << quint64(j->at(k)->id);
}
}
}
} }
void writeStickers() { void writeStickers() {
@ -2881,6 +2891,14 @@ namespace Local {
// loc // loc
size += _storageImageLocationSize(); size += _storageImageLocationSize();
} }
if (AppVersion > 9018) {
size += sizeof(qint32); // emojiCount
for (StickersByEmojiMap::const_iterator j = i->emoji.cbegin(), e = i->emoji.cend(); j != e; ++j) {
size += _stringSize(emojiString(j.key())) + sizeof(qint32) + (j->size() * sizeof(quint64));
}
}
++setsCount; ++setsCount;
} }
@ -2920,8 +2938,6 @@ namespace Local {
RecentStickerPack &recent(cRefRecentStickers()); RecentStickerPack &recent(cRefRecentStickers());
recent.clear(); recent.clear();
Global::SetStickersByEmoji(StickersByEmojiMap());
StickerSet &def(sets.insert(DefaultStickerSetId, StickerSet(DefaultStickerSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::flag_official)).value()); StickerSet &def(sets.insert(DefaultStickerSetId, StickerSet(DefaultStickerSetId, 0, lang(lng_stickers_default_set), QString(), 0, 0, MTPDstickerSet::flag_official)).value());
StickerSet &custom(sets.insert(CustomStickerSetId, StickerSet(CustomStickerSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, 0)).value()); StickerSet &custom(sets.insert(CustomStickerSetId, StickerSet(CustomStickerSetId, 0, lang(lng_custom_stickers), QString(), 0, 0, 0)).value());
@ -2995,8 +3011,6 @@ namespace Local {
StickerSetsOrder &order(cRefStickerSetsOrder()); StickerSetsOrder &order(cRefStickerSetsOrder());
order.clear(); order.clear();
Global::SetStickersByEmoji(StickersByEmojiMap());
quint32 cnt; quint32 cnt;
QByteArray hash; QByteArray hash;
stickers.stream >> cnt >> hash; // ignore hash, it is counted stickers.stream >> cnt >> hash; // ignore hash, it is counted
@ -3078,8 +3092,27 @@ namespace Local {
++set.count; ++set.count;
} }
if (setId != CustomStickerSetId) { if (stickers.version > 9018) {
Global::StickersByEmoji_AddPack(set.stickers); qint32 emojiCount;
stickers.stream >> emojiCount;
for (int32 j = 0; j < emojiCount; ++j) {
QString emojiString;
qint32 stickersCount;
stickers.stream >> emojiString >> stickersCount;
StickerPack pack;
pack.reserve(stickersCount);
for (int32 k = 0; k < stickersCount; ++k) {
quint64 id;
stickers.stream >> id;
DocumentData *doc = App::document(id);
if (!doc || !doc->sticker()) continue;
pack.push_back(doc);
}
if (EmojiPtr e = emojiGetNoColor(emojiFromText(emojiString))) {
set.emoji.insert(e, pack);
}
}
} }
} }
} }

View File

@ -4594,27 +4594,41 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
if (d.vstickerset.type() == mtpc_messages_stickerSet) { if (d.vstickerset.type() == mtpc_messages_stickerSet) {
const MTPDmessages_stickerSet &set(d.vstickerset.c_messages_stickerSet()); const MTPDmessages_stickerSet &set(d.vstickerset.c_messages_stickerSet());
if (set.vset.type() == mtpc_stickerSet) { if (set.vset.type() == mtpc_stickerSet) {
const QVector<MTPDocument> &v(set.vdocuments.c_vector().v);
StickerPack pack;
pack.reserve(v.size());
for (int32 i = 0, l = v.size(); i < l; ++i) {
DocumentData *doc = App::feedDocument(v.at(i));
if (!doc || !doc->sticker()) continue;
pack.push_back(doc);
}
const MTPDstickerSet &s(set.vset.c_stickerSet()); const MTPDstickerSet &s(set.vset.c_stickerSet());
StickerSets &sets(cRefStickerSets()); StickerSets &sets(cRefStickerSets());
StickerSets::iterator it = sets.find(s.vid.v); StickerSets::iterator it = sets.find(s.vid.v);
if (it != sets.cend()) { if (it == sets.cend()) {
Global::StickersByEmoji_RemovePack(it->stickers);
} else {
it = sets.insert(s.vid.v, StickerSet(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v)); it = sets.insert(s.vid.v, StickerSet(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v));
} }
it->stickers = pack;
Global::StickersByEmoji_AddPack(pack); const QVector<MTPDocument> &v(set.vdocuments.c_vector().v);
it->stickers.clear();
it->stickers.reserve(v.size());
for (int32 i = 0, l = v.size(); i < l; ++i) {
DocumentData *doc = App::feedDocument(v.at(i));
if (!doc || !doc->sticker()) continue;
it->stickers.push_back(doc);
}
it->emoji.clear();
const QVector<MTPStickerPack> &packs(set.vpacks.c_vector().v);
for (int32 i = 0, l = packs.size(); i < l; ++i) {
if (packs.at(i).type() != mtpc_stickerPack) continue;
const MTPDstickerPack &pack(packs.at(i).c_stickerPack());
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
const QVector<MTPlong> &stickers(pack.vdocuments.c_vector().v);
StickerPack p;
p.reserve(stickers.size());
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
DocumentData *doc = App::document(stickers.at(j).v);
if (!doc || !doc->sticker()) continue;
p.push_back(doc);
}
it->emoji.insert(e, p);
}
}
StickerSetsOrder &order(cRefStickerSetsOrder()); StickerSetsOrder &order(cRefStickerSetsOrder());
int32 insertAtIndex = 0, currentIndex = order.indexOf(s.vid.v); int32 insertAtIndex = 0, currentIndex = order.indexOf(s.vid.v);
@ -4627,8 +4641,8 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
StickerSets::iterator custom = sets.find(CustomStickerSetId); StickerSets::iterator custom = sets.find(CustomStickerSetId);
if (custom != sets.cend()) { if (custom != sets.cend()) {
for (int32 i = 0, l = pack.size(); i < l; ++i) { for (int32 i = 0, l = it->stickers.size(); i < l; ++i) {
int32 removeIndex = custom->stickers.indexOf(pack.at(i)); int32 removeIndex = custom->stickers.indexOf(it->stickers.at(i));
if (removeIndex >= 0) custom->stickers.removeAt(removeIndex); if (removeIndex >= 0) custom->stickers.removeAt(removeIndex);
} }
if (custom->stickers.isEmpty()) { if (custom->stickers.isEmpty()) {

View File

@ -209,6 +209,8 @@ DeclareRefSetting(RecentStickerPack, RecentStickers);
RecentStickerPack &cGetRecentStickers(); RecentStickerPack &cGetRecentStickers();
typedef QMap<EmojiPtr, StickerPack> StickersByEmojiMap;
static const uint64 DefaultStickerSetId = 0; // for backward compatibility static const uint64 DefaultStickerSetId = 0; // for backward compatibility
static const uint64 CustomStickerSetId = 0xFFFFFFFFFFFFFFFFULL, RecentStickerSetId = 0xFFFFFFFFFFFFFFFEULL; static const uint64 CustomStickerSetId = 0xFFFFFFFFFFFFFFFFULL, RecentStickerSetId = 0xFFFFFFFFFFFFFFFEULL;
static const uint64 NoneStickerSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel static const uint64 NoneStickerSetId = 0xFFFFFFFFFFFFFFFDULL; // for emoji/stickers panel
@ -219,6 +221,7 @@ struct StickerSet {
QString title, shortName; QString title, shortName;
int32 count, hash, flags; int32 count, hash, flags;
StickerPack stickers; StickerPack stickers;
StickersByEmojiMap emoji;
}; };
typedef QMap<uint64, StickerSet> StickerSets; typedef QMap<uint64, StickerSet> StickerSets;
DeclareRefSetting(StickerSets, StickerSets); DeclareRefSetting(StickerSets, StickerSets);

View File

@ -1513,8 +1513,6 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
_additional = 0; _additional = 0;
} break; } break;
case mtpc_documentAttributeSticker: { case mtpc_documentAttributeSticker: {
bool wasByEmoji = Global::StickersByEmoji_Remove(this);
const MTPDdocumentAttributeSticker &d(attributes[i].c_documentAttributeSticker()); const MTPDdocumentAttributeSticker &d(attributes[i].c_documentAttributeSticker());
if (type == FileDocument) { if (type == FileDocument) {
type = StickerDocument; type = StickerDocument;
@ -1524,7 +1522,6 @@ void DocumentData::setattributes(const QVector<MTPDocumentAttribute> &attributes
if (sticker()) { if (sticker()) {
sticker()->alt = qs(d.valt); sticker()->alt = qs(d.valt);
sticker()->set = d.vstickerset; sticker()->set = d.vstickerset;
if (wasByEmoji) Global::StickersByEmoji_Add(this);
} }
} break; } break;
case mtpc_documentAttributeVideo: { case mtpc_documentAttributeVideo: {

View File

@ -11,7 +11,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.9.18</string> <string>0.9.19</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleURLTypes</key> <key>CFBundleURLTypes</key>

View File

@ -34,8 +34,8 @@ IDI_ICON1 ICON "SourceFiles\\art\\icon256.ico"
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,9,18,0 FILEVERSION 0,9,19,0
PRODUCTVERSION 0,9,18,0 PRODUCTVERSION 0,9,19,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -51,10 +51,10 @@ BEGIN
BLOCK "040904b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "CompanyName", "Telegram Messenger LLP" VALUE "CompanyName", "Telegram Messenger LLP"
VALUE "FileVersion", "0.9.18.0" VALUE "FileVersion", "0.9.19.0"
VALUE "LegalCopyright", "Copyright (C) 2013" VALUE "LegalCopyright", "Copyright (C) 2013"
VALUE "ProductName", "Telegram Desktop" VALUE "ProductName", "Telegram Desktop"
VALUE "ProductVersion", "0.9.18.0" VALUE "ProductVersion", "0.9.19.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -1701,7 +1701,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.18; CURRENT_PROJECT_VERSION = 0.9.19;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0; GCC_OPTIMIZATION_LEVEL = 0;
@ -1720,7 +1720,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COPY_PHASE_STRIP = YES; COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 0.9.18; CURRENT_PROJECT_VERSION = 0.9.19;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_OPTIMIZATION_LEVEL = fast; GCC_OPTIMIZATION_LEVEL = fast;
GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h;
@ -1747,10 +1747,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.18; CURRENT_PROJECT_VERSION = 0.9.19;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 0.9; DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.18; DYLIB_CURRENT_VERSION = 0.9.19;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
@ -1882,10 +1882,10 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 0.9.18; CURRENT_PROJECT_VERSION = 0.9.19;
DEBUG_INFORMATION_FORMAT = dwarf; DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 0.9; DYLIB_COMPATIBILITY_VERSION = 0.9;
DYLIB_CURRENT_VERSION = 0.9.18; DYLIB_CURRENT_VERSION = 0.9.19;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES; ENABLE_TESTABILITY = YES;
FRAMEWORK_SEARCH_PATHS = ""; FRAMEWORK_SEARCH_PATHS = "";

View File

@ -1,6 +1,6 @@
AppVersion 9018 AppVersion 9019
AppVersionStrMajor 0.9 AppVersionStrMajor 0.9
AppVersionStrSmall 0.9.18 AppVersionStrSmall 0.9.19
AppVersionStr 0.9.18 AppVersionStr 0.9.19
DevChannel 0 DevChannel 1
BetaVersion 0 9015008 BetaVersion 0 9015008