feat: берсерк. Регенерация profile если сервер его не отдал
This commit is contained in:
@@ -1,20 +1,24 @@
|
||||
class DebugTest {
|
||||
static bool enabled = false;
|
||||
static int contactCount = 0;
|
||||
static bool berserk = false;
|
||||
|
||||
static const int debugAccountId = -424242;
|
||||
|
||||
static const bool _envEnabled = bool.fromEnvironment('DEBUG_TEST');
|
||||
static const bool _envBerserk = bool.fromEnvironment('BERSERK');
|
||||
static const int _envContacts = int.fromEnvironment(
|
||||
'DEBUG_CONTACTS',
|
||||
defaultValue: -1,
|
||||
);
|
||||
|
||||
static const String _flag = '--debug-test';
|
||||
static const String _berserkFlag = '--berserk';
|
||||
static const String _contactsFlag = '--contacts';
|
||||
|
||||
static void parse(List<String> args) {
|
||||
if (_envEnabled) enabled = true;
|
||||
if (_envBerserk) berserk = true;
|
||||
if (_envContacts >= 0) {
|
||||
enabled = true;
|
||||
contactCount = _envContacts;
|
||||
@@ -24,6 +28,8 @@ class DebugTest {
|
||||
final arg = args[i];
|
||||
if (arg == _flag) {
|
||||
enabled = true;
|
||||
} else if (arg == _berserkFlag) {
|
||||
berserk = true;
|
||||
} else if (arg.startsWith('$_contactsFlag=')) {
|
||||
enabled = true;
|
||||
contactCount =
|
||||
|
||||
@@ -36,6 +36,15 @@ class ProfileData {
|
||||
this.profileOptions,
|
||||
});
|
||||
|
||||
factory ProfileData.stub(int id) => ProfileData(
|
||||
id: id,
|
||||
firstName: '',
|
||||
phone: 0,
|
||||
country: '',
|
||||
accountStatus: 0,
|
||||
updateTime: 0,
|
||||
);
|
||||
|
||||
factory ProfileData.fromServerProfile(Map<dynamic, dynamic> profile) {
|
||||
final contact = profile['contact'];
|
||||
if (contact is! Map) {
|
||||
@@ -70,7 +79,7 @@ class ProfileData {
|
||||
id: contact['id'] as int,
|
||||
firstName: firstName,
|
||||
lastName: lastName,
|
||||
phone: contact['phone'] as int,
|
||||
phone: (contact['phone'] as int?) ?? 0,
|
||||
photoId: contact['photoId'] as int?,
|
||||
baseUrl: contact['baseUrl'] as String?,
|
||||
baseRawUrl: contact['baseRawUrl'] as String?,
|
||||
|
||||
Reference in New Issue
Block a user