2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Save themes, apply and close editor on save.

This commit is contained in:
John Preston
2019-09-06 14:33:51 +03:00
parent 910f16312c
commit 9c86f0e0a5
9 changed files with 122 additions and 53 deletions

View File

@@ -78,4 +78,12 @@ const std::vector<CloudTheme> &CloudThemes::list() const {
return _list;
}
void CloudThemes::apply(const CloudTheme &theme) {
const auto i = ranges::find(_list, theme.id, &CloudTheme::id);
if (i != end(_list)) {
*i = theme;
_updates.fire({});
}
}
} // namespace Data

View File

@@ -35,6 +35,7 @@ public:
void refresh();
[[nodiscard]] rpl::producer<> updated() const;
[[nodiscard]] const std::vector<CloudTheme> &list() const;
void apply(const CloudTheme &data);
private:
void parseThemes(const QVector<MTPTheme> &list);

View File

@@ -568,6 +568,17 @@ void DocumentData::validateLottieSticker() {
}
}
void DocumentData::setDataAndCache(const QByteArray &data) {
setData(data);
if (saveToCache() && data.size() <= Storage::kMaxFileInMemory) {
session().data().cache().put(
cacheKey(),
Storage::Cache::Database::TaggedValue(
base::duplicate(data),
cacheTag()));
}
}
bool DocumentData::checkWallPaperProperties() {
if (type == WallPaperDocument) {
return true;

View File

@@ -166,6 +166,7 @@ public:
void setData(const QByteArray &data) {
_data = data;
}
void setDataAndCache(const QByteArray &data);
bool checkWallPaperProperties();
[[nodiscard]] bool isWallPaper() const;
[[nodiscard]] bool isPatternWallPaper() const;