mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Check support mode on full self load.
This commit is contained in:
@@ -2025,6 +2025,10 @@ void Account::readStickerSets(
|
||||
Data::StickersSetFlags readingFlags) {
|
||||
using SetFlag = Data::StickersSetFlag;
|
||||
|
||||
if (!stickersKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
FileReadDescriptor stickers;
|
||||
if (!ReadEncryptedFile(stickers, stickersKey, _basePath, _localKey)) {
|
||||
ClearKey(stickersKey, _basePath);
|
||||
@@ -2948,12 +2952,16 @@ void Account::writeExportSettings(const Export::Settings &settings) {
|
||||
}
|
||||
|
||||
Export::Settings Account::readExportSettings() {
|
||||
if (!_exportSettingsKey) {
|
||||
return {};
|
||||
}
|
||||
|
||||
FileReadDescriptor file;
|
||||
if (!ReadEncryptedFile(file, _exportSettingsKey, _basePath, _localKey)) {
|
||||
ClearKey(_exportSettingsKey, _basePath);
|
||||
_exportSettingsKey = 0;
|
||||
writeMapDelayed();
|
||||
return Export::Settings();
|
||||
return {};
|
||||
}
|
||||
|
||||
quint32 types = 0, fullChats = 0;
|
||||
|
||||
@@ -17,12 +17,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_text_entities.h"
|
||||
#include "history/history.h"
|
||||
#include "boxes/abstract_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_entity.h"
|
||||
#include "ui/text/text_options.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/widgets/fields/input_field.h"
|
||||
#include "chat_helpers/message_field.h"
|
||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||
#include "base/unixtime.h"
|
||||
@@ -292,8 +293,32 @@ Helper::Helper(not_null<Main::Session*> session)
|
||||
|
||||
std::unique_ptr<Helper> Helper::Create(not_null<Main::Session*> session) {
|
||||
//return std::make_unique<Helper>(session); AssertIsDebug();
|
||||
const auto valid = session->user()->phone().startsWith(u"424"_q);
|
||||
return valid ? std::make_unique<Helper>(session) : nullptr;
|
||||
return ShouldUse(session) ? std::make_unique<Helper>(session) : nullptr;
|
||||
}
|
||||
|
||||
void Helper::CheckIfLost(not_null<Window::SessionController*> controller) {
|
||||
static auto Checked = false;
|
||||
if (Checked) {
|
||||
return;
|
||||
}
|
||||
Checked = true;
|
||||
|
||||
const auto session = &controller->session();
|
||||
if (!ShouldUse(session) || session->supportMode()) {
|
||||
return;
|
||||
}
|
||||
session->local().writeSelf();
|
||||
controller->show(Ui::MakeConfirmBox({
|
||||
.text = u"This account should have support mode, "
|
||||
"but it seems it was lost. Restart?"_q,
|
||||
.confirmed = [=] { Core::Restart(); },
|
||||
.confirmText = u"Restart"_q,
|
||||
.title = u"Support Mode Lost"_q,
|
||||
}));
|
||||
}
|
||||
|
||||
bool Helper::ShouldUse(not_null<Main::Session*> session) {
|
||||
return session->user()->phone().startsWith(u"424"_q);
|
||||
}
|
||||
|
||||
void Helper::registerWindow(not_null<Window::SessionController*> controller) {
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
explicit Helper(not_null<Main::Session*> session);
|
||||
|
||||
static std::unique_ptr<Helper> Create(not_null<Main::Session*> session);
|
||||
static void CheckIfLost(not_null<Window::SessionController*> controller);
|
||||
|
||||
void registerWindow(not_null<Window::SessionController*> controller);
|
||||
void cloudDraftChanged(not_null<History*> history);
|
||||
@@ -92,6 +93,8 @@ private:
|
||||
TextWithEntities text,
|
||||
Fn<void(bool success)> done);
|
||||
|
||||
static bool ShouldUse(not_null<Main::Session*> session);
|
||||
|
||||
const not_null<Main::Session*> _session;
|
||||
MTP::Sender _api;
|
||||
Templates _templates;
|
||||
|
||||
@@ -1573,6 +1573,9 @@ SessionController::SessionController(
|
||||
}
|
||||
}
|
||||
if (update.flags & Data::PeerUpdate::Flag::FullInfo) {
|
||||
if (update.peer->isSelf()) {
|
||||
Support::Helper::CheckIfLost(this);
|
||||
}
|
||||
fullInfoLoadedHook(update.peer);
|
||||
}
|
||||
return (update.flags & Data::PeerUpdate::Flag::FullInfo)
|
||||
|
||||
Reference in New Issue
Block a user