Push new saved theme to the list.

This commit is contained in:
John Preston 2019-09-08 21:01:45 +03:00
parent bb7018424a
commit 2ab2eed633
3 changed files with 6 additions and 3 deletions

View File

@ -282,11 +282,14 @@ const std::vector<CloudTheme> &CloudThemes::list() const {
return _list;
}
void CloudThemes::apply(const CloudTheme &theme) {
void CloudThemes::savedFromEditor(const CloudTheme &theme) {
const auto i = ranges::find(_list, theme.id, &CloudTheme::id);
if (i != end(_list)) {
*i = theme;
_updates.fire({});
} else {
_list.insert(begin(_list), theme);
_updates.fire({});
}
}

View File

@ -39,7 +39,7 @@ public:
void refresh();
[[nodiscard]] rpl::producer<> updated() const;
[[nodiscard]] const std::vector<CloudTheme> &list() const;
void apply(const CloudTheme &data);
void savedFromEditor(const CloudTheme &data);
void remove(uint64 cloudThemeId);
void applyUpdate(const MTPTheme &theme);

View File

@ -549,7 +549,7 @@ Fn<void()> SavePreparedTheme(
const auto cloud = result.match([&](const MTPDtheme &data) {
const auto result = Data::CloudTheme::Parse(session, data);
session->data().cloudThemes().apply(result);
session->data().cloudThemes().savedFromEditor(result);
return result;
}, [&](const MTPDthemeDocumentNotModified &data) {
LOG(("API Error: Unexpected themeDocumentNotModified."));