mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-30 07:18:28 +00:00
Send theme install requests.
This commit is contained in:
parent
e3d7bf771f
commit
e38123cc48
@ -63,6 +63,7 @@ void CloudThemes::setupReload() {
|
||||
}) | rpl::map([=] {
|
||||
return needReload();
|
||||
}) | rpl::start_with_next([=](bool need) {
|
||||
install();
|
||||
if (need) {
|
||||
scheduleReload();
|
||||
} else {
|
||||
@ -76,6 +77,29 @@ bool CloudThemes::needReload() const {
|
||||
return fields.id && fields.documentId;
|
||||
}
|
||||
|
||||
void CloudThemes::install() {
|
||||
using namespace Window::Theme;
|
||||
|
||||
const auto &fields = Background()->themeObject().cloud;
|
||||
auto &themeId = IsNightMode()
|
||||
? _installedNightThemeId
|
||||
: _installedDayThemeId;
|
||||
const auto cloudId = fields.documentId ? fields.id : uint64(0);
|
||||
if (themeId == cloudId) {
|
||||
return;
|
||||
}
|
||||
themeId = cloudId;
|
||||
using Flag = MTPaccount_InstallTheme::Flag;
|
||||
const auto flags = (IsNightMode() ? Flag::f_dark : Flag(0))
|
||||
| Flag::f_format
|
||||
| (themeId ? Flag::f_theme : Flag(0));
|
||||
_session->api().request(MTPaccount_InstallTheme(
|
||||
MTP_flags(flags),
|
||||
MTP_string(Format()),
|
||||
MTP_inputTheme(MTP_long(cloudId), MTP_long(fields.accessHash))
|
||||
)).send();
|
||||
}
|
||||
|
||||
void CloudThemes::reloadCurrent() {
|
||||
if (!needReload()) {
|
||||
return;
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
private:
|
||||
void parseThemes(const QVector<MTPTheme> &list);
|
||||
|
||||
void install();
|
||||
void setupReload();
|
||||
[[nodiscard]] bool needReload() const;
|
||||
void scheduleReload();
|
||||
@ -63,6 +64,8 @@ private:
|
||||
base::Timer _reloadCurrentTimer;
|
||||
DocumentData *_updatingFrom = nullptr;
|
||||
rpl::lifetime _updatingFromLifetime;
|
||||
uint64 _installedDayThemeId = 0;
|
||||
uint64 _installedNightThemeId = 0;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user