mirror of
https://github.com/telegramdesktop/tdesktop
synced 2024-12-29 01:52:48 +00:00
Fixed reading stickers from old versioned local storage.
Handling error when installing sticker set from featured.
This commit is contained in:
parent
640f9d7389
commit
bf4acc4e52
@ -155,11 +155,11 @@ void StickerSetInner::installDone(const MTPBool &result) {
|
||||
emit installed(_setId);
|
||||
}
|
||||
|
||||
bool StickerSetInner::installFailed(const RPCError &error) {
|
||||
bool StickerSetInner::installFail(const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
if (error.type() == qstr("STICKERSETS_TOO_MUCH")) {
|
||||
Ui::showLayer(new InformBox(lang(lng_stickers_too_many_packs)));
|
||||
Ui::showLayer(new InformBox(lang(lng_stickers_too_many_packs)), KeepOtherLayers);
|
||||
} else {
|
||||
Ui::showLayer(new InformBox(lang(lng_stickers_not_found)));
|
||||
}
|
||||
@ -283,7 +283,7 @@ QString StickerSetInner::shortName() const {
|
||||
|
||||
void StickerSetInner::install() {
|
||||
if (_installRequest) return;
|
||||
_installRequest = MTP::send(MTPmessages_InstallStickerSet(_input, MTP_bool(false)), rpcDone(&StickerSetInner::installDone), rpcFail(&StickerSetInner::installFailed));
|
||||
_installRequest = MTP::send(MTPmessages_InstallStickerSet(_input, MTP_bool(false)), rpcDone(&StickerSetInner::installDone), rpcFail(&StickerSetInner::installFail));
|
||||
}
|
||||
|
||||
StickerSetInner::~StickerSetInner() {
|
||||
@ -734,7 +734,7 @@ void StickersInner::installSet(uint64 setId) {
|
||||
return;
|
||||
}
|
||||
|
||||
MTP::send(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_boolFalse()));
|
||||
MTP::send(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_boolFalse()), RPCDoneHandlerPtr(), rpcFail(&StickersInner::installFail, setId));
|
||||
|
||||
it->flags &= ~(MTPDstickerSet::Flag::f_disabled | MTPDstickerSet_ClientFlag::f_unread);
|
||||
it->flags |= MTPDstickerSet::Flag::f_installed;
|
||||
@ -762,6 +762,36 @@ void StickersInner::installSet(uint64 setId) {
|
||||
emit App::main()->stickersUpdated();
|
||||
}
|
||||
|
||||
bool StickersInner::installFail(uint64 setId, const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
auto &sets = Global::RefStickerSets();
|
||||
auto it = sets.find(setId);
|
||||
if (it == sets.cend()) {
|
||||
rebuild();
|
||||
return true;
|
||||
}
|
||||
|
||||
it->flags &= ~MTPDstickerSet::Flag::f_installed;
|
||||
|
||||
auto &order = Global::RefStickerSetsOrder();
|
||||
int currentIndex = order.indexOf(setId);
|
||||
if (currentIndex >= 0) {
|
||||
order.removeAt(currentIndex);
|
||||
}
|
||||
|
||||
Local::writeStickers();
|
||||
emit App::main()->stickersUpdated();
|
||||
|
||||
if (error.type() == qstr("STICKERSETS_TOO_MUCH")) {
|
||||
Ui::showLayer(new InformBox(lang(lng_stickers_too_many_packs)), KeepOtherLayers);
|
||||
} else {
|
||||
Ui::showLayer(new InformBox(lang(lng_stickers_not_found)), KeepOtherLayers);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StickersInner::step_shifting(uint64 ms, bool timer) {
|
||||
bool animating = false;
|
||||
int32 updateMin = -1, updateMax = 0;
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
bool failedSet(const RPCError &error);
|
||||
|
||||
void installDone(const MTPBool &result);
|
||||
bool installFailed(const RPCError &error);
|
||||
bool installFail(const RPCError &error);
|
||||
|
||||
StickerPack _pack;
|
||||
StickersByEmojiMap _emoji;
|
||||
@ -232,6 +232,7 @@ private:
|
||||
float64 aboveShadowOpacity() const;
|
||||
|
||||
void installSet(uint64 setId);
|
||||
bool installFail(uint64 setId, const RPCError &error);
|
||||
void readFeaturedDone(const MTPBool &result);
|
||||
bool readFeaturedFail(const RPCError &error);
|
||||
|
||||
|
@ -3214,20 +3214,20 @@ namespace Local {
|
||||
setFlags |= qFlags(MTPDstickerSet_ClientFlag::f_not_loaded);
|
||||
}
|
||||
}
|
||||
if (stickers.version < 9057) {
|
||||
if (stickers.version < 9058) {
|
||||
setFlags |= qFlags(MTPDstickerSet::Flag::f_installed);
|
||||
}
|
||||
|
||||
if (setId == Stickers::DefaultSetId) {
|
||||
setTitle = lang(lng_stickers_default_set);
|
||||
setFlags |= qFlags(MTPDstickerSet::Flag::f_official);
|
||||
if (stickers.version < 9057) {
|
||||
if (stickers.version < 9058) {
|
||||
order.push_front(setId);
|
||||
}
|
||||
} else if (setId == Stickers::CustomSetId) {
|
||||
setTitle = lang(lng_custom_stickers);
|
||||
} else if (setId) {
|
||||
if (stickers.version < 9057) {
|
||||
if (stickers.version < 9058) {
|
||||
order.push_back(setId);
|
||||
}
|
||||
} else {
|
||||
@ -3282,29 +3282,29 @@ namespace Local {
|
||||
}
|
||||
|
||||
// Read orders of installed and featured stickers.
|
||||
if (stickers.version >= 9057) {
|
||||
if (stickers.version >= 9058) {
|
||||
stickers.stream >> order;
|
||||
stickers.stream >> featuredOrder;
|
||||
|
||||
// Set flags and count unread featured sets.
|
||||
for_const (auto setId, order) {
|
||||
auto it = sets.find(setId);
|
||||
if (it != sets.cend()) {
|
||||
it->flags |= MTPDstickerSet::Flag::f_installed;
|
||||
}
|
||||
}
|
||||
int unreadCount = 0;
|
||||
for_const (auto setId, featuredOrder) {
|
||||
auto it = sets.find(setId);
|
||||
if (it != sets.cend()) {
|
||||
it->flags |= MTPDstickerSet_ClientFlag::f_featured;
|
||||
if (it->flags & MTPDstickerSet_ClientFlag::f_unread) {
|
||||
++unreadCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Global::SetFeaturedStickerSetsUnreadCount(unreadCount);
|
||||
}
|
||||
|
||||
// Set flags and count unread featured sets.
|
||||
for_const (auto setId, order) {
|
||||
auto it = sets.find(setId);
|
||||
if (it != sets.cend()) {
|
||||
it->flags |= MTPDstickerSet::Flag::f_installed;
|
||||
}
|
||||
}
|
||||
int unreadCount = 0;
|
||||
for_const (auto setId, featuredOrder) {
|
||||
auto it = sets.find(setId);
|
||||
if (it != sets.cend()) {
|
||||
it->flags |= MTPDstickerSet_ClientFlag::f_featured;
|
||||
if (it->flags & MTPDstickerSet_ClientFlag::f_unread) {
|
||||
++unreadCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
Global::SetFeaturedStickerSetsUnreadCount(unreadCount);
|
||||
}
|
||||
|
||||
int32 countStickersHash(bool checkOfficial) {
|
||||
|
@ -3488,7 +3488,6 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
||||
switch (invite.type()) {
|
||||
case mtpc_chatInvite: {
|
||||
auto &d(invite.c_chatInvite());
|
||||
((d.is_channel() && !d.is_megagroup()) ? lng_group_invite_want_join_channel : lng_group_invite_want_join)(lt_title, qs(d.vtitle)), lang(lng_group_invite_join);
|
||||
|
||||
QVector<UserData*> participants;
|
||||
if (d.has_participants()) {
|
||||
@ -3500,7 +3499,7 @@ void MainWidget::inviteCheckDone(QString hash, const MTPChatInvite &invite) {
|
||||
}
|
||||
}
|
||||
}
|
||||
auto box = std_::make_unique<ConfirmInviteBox>(qs(d.vtitle), d.vphoto, 3, participants);
|
||||
auto box = std_::make_unique<ConfirmInviteBox>(qs(d.vtitle), d.vphoto, d.vparticipants_count.v, participants);
|
||||
_inviteHash = hash;
|
||||
Ui::showLayer(box.release());
|
||||
} break;
|
||||
|
@ -549,7 +549,7 @@ chatInviteEmpty#69df3769 = ExportedChatInvite;
|
||||
chatInviteExported#fc2e05bc link:string = ExportedChatInvite;
|
||||
|
||||
chatInviteAlready#5a686d7c chat:Chat = ChatInvite;
|
||||
chatInvite#2d492881 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:ChatPhoto participants:flags.4?Vector<User> = ChatInvite;
|
||||
chatInvite#db74f558 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true title:string photo:ChatPhoto participants_count:int participants:flags.4?Vector<User> = ChatInvite;
|
||||
|
||||
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
|
||||
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
|
||||
|
@ -4350,7 +4350,8 @@ void _serialize_chatInvite(MTPStringLogger &to, int32 stage, int32 lev, Types &t
|
||||
case 4: to.add(" megagroup: "); ++stages.back(); if (flag & MTPDchatInvite::Flag::f_megagroup) { to.add("YES [ BY BIT 3 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 3 IN FIELD flags ]"); } break;
|
||||
case 5: to.add(" title: "); ++stages.back(); types.push_back(mtpc_string+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 6: to.add(" photo: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 7: to.add(" participants: "); ++stages.back(); if (flag & MTPDchatInvite::Flag::f_participants) { types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break;
|
||||
case 7: to.add(" participants_count: "); ++stages.back(); types.push_back(mtpc_int+0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 8: to.add(" participants: "); ++stages.back(); if (flag & MTPDchatInvite::Flag::f_participants) { types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); } else { to.add("[ SKIPPED BY BIT 4 IN FIELD flags ]"); } break;
|
||||
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
|
||||
}
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ enum {
|
||||
mtpc_chatInviteEmpty = 0x69df3769,
|
||||
mtpc_chatInviteExported = 0xfc2e05bc,
|
||||
mtpc_chatInviteAlready = 0x5a686d7c,
|
||||
mtpc_chatInvite = 0x2d492881,
|
||||
mtpc_chatInvite = 0xdb74f558,
|
||||
mtpc_inputStickerSetEmpty = 0xffb62b95,
|
||||
mtpc_inputStickerSetID = 0x9de7a269,
|
||||
mtpc_inputStickerSetShortName = 0x861cc8a0,
|
||||
@ -13160,12 +13160,13 @@ public:
|
||||
|
||||
MTPDchatInvite() {
|
||||
}
|
||||
MTPDchatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, const MTPVector<MTPUser> &_participants) : vflags(_flags), vtitle(_title), vphoto(_photo), vparticipants(_participants) {
|
||||
MTPDchatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, MTPint _participants_count, const MTPVector<MTPUser> &_participants) : vflags(_flags), vtitle(_title), vphoto(_photo), vparticipants_count(_participants_count), vparticipants(_participants) {
|
||||
}
|
||||
|
||||
MTPflags<MTPDchatInvite::Flags> vflags;
|
||||
MTPstring vtitle;
|
||||
MTPChatPhoto vphoto;
|
||||
MTPint vparticipants_count;
|
||||
MTPVector<MTPUser> vparticipants;
|
||||
};
|
||||
|
||||
@ -23580,8 +23581,8 @@ public:
|
||||
inline static MTPchatInvite new_chatInviteAlready(const MTPChat &_chat) {
|
||||
return MTPchatInvite(new MTPDchatInviteAlready(_chat));
|
||||
}
|
||||
inline static MTPchatInvite new_chatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, const MTPVector<MTPUser> &_participants) {
|
||||
return MTPchatInvite(new MTPDchatInvite(_flags, _title, _photo, _participants));
|
||||
inline static MTPchatInvite new_chatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, MTPint _participants_count, const MTPVector<MTPUser> &_participants) {
|
||||
return MTPchatInvite(new MTPDchatInvite(_flags, _title, _photo, _participants_count, _participants));
|
||||
}
|
||||
inline static MTPinputStickerSet new_inputStickerSetEmpty() {
|
||||
return MTPinputStickerSet(mtpc_inputStickerSetEmpty);
|
||||
@ -32441,7 +32442,7 @@ inline uint32 MTPchatInvite::innerLength() const {
|
||||
}
|
||||
case mtpc_chatInvite: {
|
||||
const MTPDchatInvite &v(c_chatInvite());
|
||||
return v.vflags.innerLength() + v.vtitle.innerLength() + v.vphoto.innerLength() + (v.has_participants() ? v.vparticipants.innerLength() : 0);
|
||||
return v.vflags.innerLength() + v.vtitle.innerLength() + v.vphoto.innerLength() + v.vparticipants_count.innerLength() + (v.has_participants() ? v.vparticipants.innerLength() : 0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -32464,6 +32465,7 @@ inline void MTPchatInvite::read(const mtpPrime *&from, const mtpPrime *end, mtpT
|
||||
v.vflags.read(from, end);
|
||||
v.vtitle.read(from, end);
|
||||
v.vphoto.read(from, end);
|
||||
v.vparticipants_count.read(from, end);
|
||||
if (v.has_participants()) { v.vparticipants.read(from, end); } else { v.vparticipants = MTPVector<MTPUser>(); }
|
||||
} break;
|
||||
default: throw mtpErrorUnexpected(cons, "MTPchatInvite");
|
||||
@ -32480,6 +32482,7 @@ inline void MTPchatInvite::write(mtpBuffer &to) const {
|
||||
v.vflags.write(to);
|
||||
v.vtitle.write(to);
|
||||
v.vphoto.write(to);
|
||||
v.vparticipants_count.write(to);
|
||||
if (v.has_participants()) v.vparticipants.write(to);
|
||||
} break;
|
||||
}
|
||||
@ -32499,8 +32502,8 @@ inline MTPchatInvite MTP_chatInviteAlready(const MTPChat &_chat) {
|
||||
return MTP::internal::TypeCreator::new_chatInviteAlready(_chat);
|
||||
}
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(MTPDchatInvite::Flags)
|
||||
inline MTPchatInvite MTP_chatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, const MTPVector<MTPUser> &_participants) {
|
||||
return MTP::internal::TypeCreator::new_chatInvite(_flags, _title, _photo, _participants);
|
||||
inline MTPchatInvite MTP_chatInvite(const MTPflags<MTPDchatInvite::Flags> &_flags, const MTPstring &_title, const MTPChatPhoto &_photo, MTPint _participants_count, const MTPVector<MTPUser> &_participants) {
|
||||
return MTP::internal::TypeCreator::new_chatInvite(_flags, _title, _photo, _participants_count, _participants);
|
||||
}
|
||||
|
||||
inline uint32 MTPinputStickerSet::innerLength() const {
|
||||
|
@ -349,6 +349,7 @@ void BoxButton::setText(const QString &text) {
|
||||
_fullText = text;
|
||||
_textWidth = _st.font->width(_text);
|
||||
resizeToText();
|
||||
update();
|
||||
}
|
||||
|
||||
void BoxButton::resizeToText() {
|
||||
|
Loading…
Reference in New Issue
Block a user