diff --git a/Telegram/SourceFiles/data/data_cloud_themes.cpp b/Telegram/SourceFiles/data/data_cloud_themes.cpp index d0b173937..335a2c7b4 100644 --- a/Telegram/SourceFiles/data/data_cloud_themes.cpp +++ b/Telegram/SourceFiles/data/data_cloud_themes.cpp @@ -282,11 +282,14 @@ const std::vector &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({}); } } diff --git a/Telegram/SourceFiles/data/data_cloud_themes.h b/Telegram/SourceFiles/data/data_cloud_themes.h index fd0d4aaa4..ea1a87f2c 100644 --- a/Telegram/SourceFiles/data/data_cloud_themes.h +++ b/Telegram/SourceFiles/data/data_cloud_themes.h @@ -39,7 +39,7 @@ public: void refresh(); [[nodiscard]] rpl::producer<> updated() const; [[nodiscard]] const std::vector &list() const; - void apply(const CloudTheme &data); + void savedFromEditor(const CloudTheme &data); void remove(uint64 cloudThemeId); void applyUpdate(const MTPTheme &theme); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp index 78facefca..f4a92b3c6 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp @@ -549,7 +549,7 @@ Fn 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."));