Support setting default background.

GitOrigin-RevId: 756e41775f3ee60faaa36f0a244f7f43ff82ef1d
This commit is contained in:
levlam 2019-07-18 21:09:48 +03:00
parent e355cabc56
commit 2b69ae2d66
3 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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<Unit> &&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());

View File

@ -1993,6 +1993,8 @@ class CliClient final : public Actor {
send_get_background_url(td_api::make_object<td_api::backgroundTypeSolid>(0x1000000));
} else if (op == "sbg") {
send_request(td_api::make_object<td_api::searchBackground>(args));
} else if (op == "sbgd") {
send_request(td_api::make_object<td_api::setBackground>(nullptr, nullptr, as_bool(args)));
} else if (op == "sbgw" || op == "sbgwd") {
send_request(td_api::make_object<td_api::setBackground>(
td_api::make_object<td_api::inputBackgroundLocal>(as_input_file(args)),