2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Automatically load and apply old emoji set by id.

This commit is contained in:
John Preston
2020-05-07 19:06:44 +04:00
parent 942fcb9aae
commit 36997f084a
7 changed files with 43 additions and 14 deletions

View File

@@ -48,7 +48,7 @@ const auto kSets = {
using Loading = MTP::DedicatedLoader::Progress;
using SetState = BlobState;
class Loader : public BlobLoader {
class Loader final : public BlobLoader {
public:
Loader(
QObject *parent,
@@ -60,6 +60,9 @@ public:
void destroy() override;
void unpack(const QString &path) override;
private:
void fail() override;
};
class Inner : public Ui::RpWidget {
@@ -155,12 +158,14 @@ bool UnpackSet(const QString &path, const QString &folder) {
return UnpackBlob(path, folder, GoodSetPartName);
}
Loader::Loader(
QObject *parent,
int id,
MTP::DedicatedLoader::Location location,
const QString &folder,
int size) : BlobLoader(parent, id, location, folder, size) {
int size)
: BlobLoader(parent, id, location, folder, size) {
}
void Loader::unpack(const QString &path) {
@@ -190,6 +195,11 @@ void Loader::destroy() {
SetGlobalLoader(nullptr);
}
void Loader::fail() {
ClearNeedSwitchToId();
BlobLoader::fail();
}
Inner::Inner(QWidget *parent) : RpWidget(parent) {
setupContent();
}
@@ -401,12 +411,7 @@ void Row::setupHandler() {
}
void Row::load() {
SetGlobalLoader(base::make_unique_q<Loader>(
App::main(),
_id,
GetDownloadLocation(_id),
internal::SetDataPath(_id),
GetDownloadSize(_id)));
LoadAndSwitchTo(_id);
}
void Row::setupLabels(const Set &set) {
@@ -538,5 +543,20 @@ void ManageSetsBox::prepare() {
setDimensionsToContent(st::boxWidth, inner);
}
void LoadAndSwitchTo(int id) {
Expects(App::main() != nullptr);
if (!ranges::contains(kSets, id, &Set::id)) {
ClearNeedSwitchToId();
return;
}
SetGlobalLoader(base::make_unique_q<Loader>(
App::main(),
id,
GetDownloadLocation(id),
internal::SetDataPath(id),
GetDownloadSize(id)));
}
} // namespace Emoji
} // namespace Ui