mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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.hash = data.is_current() ? 0 : data.vhash().v;
|
||||||
result.incomplete = data.is_password_pending();
|
result.incomplete = data.is_password_pending();
|
||||||
|
result.callsDisabled = data.is_call_requests_disabled();
|
||||||
|
|
||||||
const auto apiId = result.apiId = data.vapi_id().v;
|
const auto apiId = result.apiId = data.vapi_id().v;
|
||||||
const auto isTest = (apiId == TestApiId);
|
const auto isTest = (apiId == TestApiId);
|
||||||
|
@ -135,6 +136,7 @@ void Authorizations::reload() {
|
||||||
) | ranges::views::transform([](const MTPAuthorization &d) {
|
) | ranges::views::transform([](const MTPAuthorization &d) {
|
||||||
return ParseEntry(d.c_authorization());
|
return ParseEntry(d.c_authorization());
|
||||||
}) | ranges::to<List>;
|
}) | ranges::to<List>;
|
||||||
|
refreshCallsDisabledHereFromCloud();
|
||||||
_listChanges.fire({});
|
_listChanges.fire({});
|
||||||
});
|
});
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
|
@ -146,6 +148,14 @@ void Authorizations::cancelCurrentRequest() {
|
||||||
_api.request(base::take(_requestId)).cancel();
|
_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(
|
void Authorizations::requestTerminate(
|
||||||
Fn<void(const MTPBool &result)> &&done,
|
Fn<void(const MTPBool &result)> &&done,
|
||||||
Fn<void(const MTP::Error &error)> &&fail,
|
Fn<void(const MTP::Error &error)> &&fail,
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
uint64 hash = 0;
|
uint64 hash = 0;
|
||||||
|
|
||||||
bool incomplete = false;
|
bool incomplete = false;
|
||||||
|
bool callsDisabled = false;
|
||||||
int apiId = 0;
|
int apiId = 0;
|
||||||
TimeId activeTime = 0;
|
TimeId activeTime = 0;
|
||||||
QString name, active, info, ip, location, system, platform;
|
QString name, active, info, ip, location, system, platform;
|
||||||
|
@ -53,6 +54,8 @@ public:
|
||||||
[[nodiscard]] rpl::producer<bool> callsDisabledHereChanges() const;
|
[[nodiscard]] rpl::producer<bool> callsDisabledHereChanges() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void refreshCallsDisabledHereFromCloud();
|
||||||
|
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
mtpRequestId _requestId = 0;
|
mtpRequestId _requestId = 0;
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,9 @@ Calls::Calls(
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
: Section(parent)
|
: Section(parent)
|
||||||
, _controller(controller) {
|
, _controller(controller) {
|
||||||
|
// Request valid value of calls disabled flag.
|
||||||
|
controller->session().api().authorizations().reload();
|
||||||
|
|
||||||
setupContent();
|
setupContent();
|
||||||
requestPermissionAndStartTestingMicrophone();
|
requestPermissionAndStartTestingMicrophone();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue