mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 15:15:13 +00:00
Send theme install requests.
This commit is contained in:
@@ -63,6 +63,7 @@ void CloudThemes::setupReload() {
|
|||||||
}) | rpl::map([=] {
|
}) | rpl::map([=] {
|
||||||
return needReload();
|
return needReload();
|
||||||
}) | rpl::start_with_next([=](bool need) {
|
}) | rpl::start_with_next([=](bool need) {
|
||||||
|
install();
|
||||||
if (need) {
|
if (need) {
|
||||||
scheduleReload();
|
scheduleReload();
|
||||||
} else {
|
} else {
|
||||||
@@ -76,6 +77,29 @@ bool CloudThemes::needReload() const {
|
|||||||
return fields.id && fields.documentId;
|
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() {
|
void CloudThemes::reloadCurrent() {
|
||||||
if (!needReload()) {
|
if (!needReload()) {
|
||||||
return;
|
return;
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void parseThemes(const QVector<MTPTheme> &list);
|
void parseThemes(const QVector<MTPTheme> &list);
|
||||||
|
|
||||||
|
void install();
|
||||||
void setupReload();
|
void setupReload();
|
||||||
[[nodiscard]] bool needReload() const;
|
[[nodiscard]] bool needReload() const;
|
||||||
void scheduleReload();
|
void scheduleReload();
|
||||||
@@ -63,6 +64,8 @@ private:
|
|||||||
base::Timer _reloadCurrentTimer;
|
base::Timer _reloadCurrentTimer;
|
||||||
DocumentData *_updatingFrom = nullptr;
|
DocumentData *_updatingFrom = nullptr;
|
||||||
rpl::lifetime _updatingFromLifetime;
|
rpl::lifetime _updatingFromLifetime;
|
||||||
|
uint64 _installedDayThemeId = 0;
|
||||||
|
uint64 _installedNightThemeId = 0;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user