mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Show correct state of "Accept calls" checkbox.
This commit is contained in:
parent
d18c6591e9
commit
856c537335
3 changed files with 16 additions and 0 deletions
|
@ -26,6 +26,7 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
|
|||
|
||||
result.hash = data.is_current() ? 0 : data.vhash().v;
|
||||
result.incomplete = data.is_password_pending();
|
||||
result.callsDisabled = data.is_call_requests_disabled();
|
||||
|
||||
const auto apiId = result.apiId = data.vapi_id().v;
|
||||
const auto isTest = (apiId == TestApiId);
|
||||
|
@ -135,6 +136,7 @@ void Authorizations::reload() {
|
|||
) | ranges::views::transform([](const MTPAuthorization &d) {
|
||||
return ParseEntry(d.c_authorization());
|
||||
}) | ranges::to<List>;
|
||||
refreshCallsDisabledHereFromCloud();
|
||||
_listChanges.fire({});
|
||||
});
|
||||
}).fail([=] {
|
||||
|
@ -146,6 +148,14 @@ void Authorizations::cancelCurrentRequest() {
|
|||
_api.request(base::take(_requestId)).cancel();
|
||||
}
|
||||
|
||||
void Authorizations::refreshCallsDisabledHereFromCloud() {
|
||||
const auto that = ranges::find(_list, 0, &Entry::hash);
|
||||
if (that != end(_list)
|
||||
&& !_toggleCallsDisabledRequests.contains(0)) {
|
||||
_callsDisabledHere = that->callsDisabled;
|
||||
}
|
||||
}
|
||||
|
||||
void Authorizations::requestTerminate(
|
||||
Fn<void(const MTPBool &result)> &&done,
|
||||
Fn<void(const MTP::Error &error)> &&fail,
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
uint64 hash = 0;
|
||||
|
||||
bool incomplete = false;
|
||||
bool callsDisabled = false;
|
||||
int apiId = 0;
|
||||
TimeId activeTime = 0;
|
||||
QString name, active, info, ip, location, system, platform;
|
||||
|
@ -53,6 +54,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> callsDisabledHereChanges() const;
|
||||
|
||||
private:
|
||||
void refreshCallsDisabledHereFromCloud();
|
||||
|
||||
MTP::Sender _api;
|
||||
mtpRequestId _requestId = 0;
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ Calls::Calls(
|
|||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
// Request valid value of calls disabled flag.
|
||||
controller->session().api().authorizations().reload();
|
||||
|
||||
setupContent();
|
||||
requestPermissionAndStartTestingMicrophone();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue