2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-10-17 14:36:45 +00:00

Allow setting custom device name.

This commit is contained in:
John Preston
2021-11-16 20:48:40 +04:00
parent f3a00abe18
commit 49544111ab
7 changed files with 153 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "base/unixtime.h"
#include "core/changelogs.h"
#include "core/application.h"
#include "lang/lang_keys.h"
namespace Api {
@@ -46,7 +47,9 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
return version;
}();
result.name = qs(data.vdevice_model());
result.name = result.hash
? qs(data.vdevice_model())
: Core::App().settings().deviceModel();
const auto country = qs(data.vcountry());
//const auto platform = qs(data.vplatform());
@@ -91,6 +94,19 @@ Authorizations::Entry ParseEntry(const MTPDauthorization &data) {
Authorizations::Authorizations(not_null<ApiWrap*> api)
: _api(&api->instance()) {
Core::App().settings().deviceModelChanges(
) | rpl::start_with_next([=](const QString &model) {
auto changed = false;
for (auto &entry : _list) {
if (!entry.hash) {
entry.name = model;
changed = true;
}
}
if (changed) {
_listChanges.fire({});
}
}, _lifetime);
}
void Authorizations::reload() {