From 2b69ae2d66e56db609017e9711a96de3edbc0c27 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 18 Jul 2019 21:09:48 +0300 Subject: [PATCH] Support setting default background. GitOrigin-RevId: 756e41775f3ee60faaa36f0a244f7f43ff82ef1d --- td/generate/scheme/td_api.tl | 4 +++- td/telegram/BackgroundManager.cpp | 6 ++++++ td/telegram/cli.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 917fcec8..da69259b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -3668,7 +3668,9 @@ getBackgroundUrl name:string type:BackgroundType = HttpUrl; searchBackground name:string = Background; //@description Changes selected by the user background; adds background to the list of installed backgrounds -//@background The input background to use, null for solid backgrounds @type Background type @for_dark_theme True, if the background is chosen for dark theme +//@background The input background to use, null for solid backgrounds +//@type Background type; null for default background. The method will return error 404 if type is null +//@for_dark_theme True, if the background is chosen for dark theme setBackground background:InputBackground type:BackgroundType for_dark_theme:Bool = Background; //@description Removes background from the list of installed backgrounds @background_id The background indentifier diff --git a/td/telegram/BackgroundManager.cpp b/td/telegram/BackgroundManager.cpp index a0b2db6e..6cc6149e 100644 --- a/td/telegram/BackgroundManager.cpp +++ b/td/telegram/BackgroundManager.cpp @@ -498,6 +498,12 @@ BackgroundId BackgroundManager::add_solid_background(int32 color) { BackgroundId BackgroundManager::set_background(const td_api::InputBackground *input_background, const td_api::BackgroundType *background_type, bool for_dark_theme, Promise &&promise) { + if (background_type == nullptr) { + set_background_id(BackgroundId(), BackgroundType(), for_dark_theme); + promise.set_value(Unit()); + return BackgroundId(); + } + auto r_type = get_background_type(background_type); if (r_type.is_error()) { promise.set_error(r_type.move_as_error()); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 7e4f9772..d6593912 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1993,6 +1993,8 @@ class CliClient final : public Actor { send_get_background_url(td_api::make_object(0x1000000)); } else if (op == "sbg") { send_request(td_api::make_object(args)); + } else if (op == "sbgd") { + send_request(td_api::make_object(nullptr, nullptr, as_bool(args))); } else if (op == "sbgw" || op == "sbgwd") { send_request(td_api::make_object( td_api::make_object(as_input_file(args)),