2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Use one place for saving restrictions.

This commit is contained in:
John Preston
2019-01-16 13:12:31 +04:00
parent 287b3509ab
commit 04350af96f
2 changed files with 28 additions and 15 deletions

View File

@@ -127,7 +127,9 @@ void SaveChannelAdmin(
)).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result);
channel->applyEditAdmin(user, oldRights, newRights);
onDone();
if (onDone) {
onDone();
}
}).fail([=](const RPCError &error) {
if (error.type() == qstr("USER_NOT_MUTUAL_CONTACT")) {
Ui::show(
@@ -147,7 +149,9 @@ void SaveChannelAdmin(
: lng_error_admin_limit_channel)),
LayerOption::KeepOther);
}
onFail();
if (onFail) {
onFail();
}
}).send();
}
@@ -165,9 +169,13 @@ void SaveChannelRestriction(
)).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result);
channel->applyEditBanned(user, oldRights, newRights);
onDone();
if (onDone) {
onDone();
}
}).fail([=](const RPCError &error) {
onFail();
if (onFail) {
onFail();
}
}).send();
}
@@ -183,7 +191,7 @@ Fn<void(
return [=](
const MTPChatAdminRights &oldRights,
const MTPChatAdminRights &newRights) {
const auto done = [=] { onDone(newRights); };
const auto done = [=] { if (onDone) onDone(newRights); };
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
SaveChannelAdmin(
channel,
@@ -226,7 +234,7 @@ Fn<void(
return [=](
const MTPChatBannedRights &oldRights,
const MTPChatBannedRights &newRights) {
const auto done = [=] { onDone(newRights); };
const auto done = [=] { if (onDone) onDone(newRights); };
const auto saveForChannel = [=](not_null<ChannelData*> channel) {
SaveChannelRestriction(
channel,