Fix setting the same background.
GitOrigin-RevId: 2f1d147f32d66916683e1a18bf4734dd8ad70407
This commit is contained in:
parent
13a6973f4b
commit
051acb85af
@ -568,9 +568,7 @@ BackgroundId BackgroundManager::set_background(const td_api::InputBackground *in
|
||||
auto type = r_type.move_as_ok();
|
||||
if (type.type == BackgroundType::Type::Fill) {
|
||||
auto background_id = add_fill_background(type.fill);
|
||||
if (set_background_id_[for_dark_theme] != background_id) {
|
||||
set_background_id(background_id, type, for_dark_theme);
|
||||
}
|
||||
set_background_id(background_id, type, for_dark_theme);
|
||||
promise.set_value(Unit());
|
||||
return background_id;
|
||||
}
|
||||
@ -612,6 +610,7 @@ BackgroundId BackgroundManager::set_background(const td_api::InputBackground *in
|
||||
|
||||
BackgroundId BackgroundManager::set_background(BackgroundId background_id, const BackgroundType &type,
|
||||
bool for_dark_theme, Promise<Unit> &&promise) {
|
||||
LOG(INFO) << "Set " << background_id << " with " << type;
|
||||
auto *background = get_background(background_id);
|
||||
if (background == nullptr) {
|
||||
promise.set_error(Status::Error(400, "Background to set not found"));
|
||||
@ -621,7 +620,7 @@ BackgroundId BackgroundManager::set_background(BackgroundId background_id, const
|
||||
promise.set_error(Status::Error(400, "Background type mismatch"));
|
||||
return BackgroundId();
|
||||
}
|
||||
if (set_background_id_[for_dark_theme] == background_id) {
|
||||
if (set_background_id_[for_dark_theme] == background_id && set_background_type_[for_dark_theme] == type) {
|
||||
promise.set_value(Unit());
|
||||
return background_id;
|
||||
}
|
||||
@ -818,6 +817,8 @@ void BackgroundManager::on_reset_background(Result<Unit> &&result, Promise<Unit>
|
||||
}
|
||||
|
||||
void BackgroundManager::add_background(const Background &background) {
|
||||
LOG(INFO) << "Add " << background.id << " of " << background.type;
|
||||
|
||||
CHECK(background.id.is_valid());
|
||||
auto *result = &backgrounds_[background.id];
|
||||
|
||||
|
@ -2148,6 +2148,10 @@ class CliClient final : public Actor {
|
||||
send_request(td_api::make_object<td_api::setBackground>(
|
||||
td_api::make_object<td_api::inputBackgroundLocal>(as_input_file(args)),
|
||||
get_solid_pattern_background(0xABCDEF, 49, true), op == "sbgpd"));
|
||||
} else if (op == "sbggp" || op == "sbggpd") {
|
||||
send_request(td_api::make_object<td_api::setBackground>(
|
||||
td_api::make_object<td_api::inputBackgroundLocal>(as_input_file(args)),
|
||||
get_gradient_pattern_background(0xABCDEF, 0xFE, 51, false), op == "sbggpd"));
|
||||
} else if (op == "sbgs" || op == "sbgsd") {
|
||||
send_request(td_api::make_object<td_api::setBackground>(nullptr, get_solid_background(to_integer<int32>(args)),
|
||||
op == "sbgsd"));
|
||||
|
Loading…
Reference in New Issue
Block a user