Merge pull request #29 from KometTeam/feature/login-success-animation
Feature/login анимация успешного входа, мультиаккаунтинг и десктоп режим
This commit is contained in:
@@ -9,6 +9,7 @@ import '../../core/utils/logger.dart';
|
||||
import 'chats.dart';
|
||||
import 'contacts.dart';
|
||||
import 'folders.dart';
|
||||
import 'messages.dart';
|
||||
|
||||
String _normalizeAuthPhone(String phone) {
|
||||
final digits = phone.replaceAll(RegExp(r'\D'), '');
|
||||
@@ -925,14 +926,34 @@ class AccountModule {
|
||||
if (profile == null) {
|
||||
throw StateError('switchAccount: аккаунт $accountId не найден в базе');
|
||||
}
|
||||
final token = await TokenStorage.readToken(accountId);
|
||||
if (token == null) {
|
||||
throw StateError('switchAccount: нет токена для аккаунта $accountId');
|
||||
}
|
||||
|
||||
try {
|
||||
await _api.disconnect();
|
||||
} catch (_) {}
|
||||
|
||||
await AppDatabase.setActiveAccount(accountId);
|
||||
await TokenStorage.setActiveAccount(accountId);
|
||||
|
||||
ContactCache.clear();
|
||||
TranscriptionCache.clear();
|
||||
await ContactsModule.primeCacheFromDb(accountId);
|
||||
|
||||
try {
|
||||
await _api.connect();
|
||||
} catch (_) {}
|
||||
|
||||
logger.i('Активный аккаунт переключён на $accountId');
|
||||
return profile;
|
||||
}
|
||||
|
||||
Future<List<ProfileData>> listAccounts() async {
|
||||
return AppDatabase.loadAllProfiles();
|
||||
}
|
||||
|
||||
Future<void> removeAccount(int accountId) async {
|
||||
await AppDatabase.deleteAccount(accountId);
|
||||
await TokenStorage.deleteAccount(accountId);
|
||||
|
||||
@@ -25,6 +25,12 @@ class ContactCache {
|
||||
static String? getAvatar(int id) => _avatarCache[id];
|
||||
static Set<String>? getOptions(int id) => _optionsCache[id];
|
||||
static bool isOfficial(int id) => _optionsCache[id]?.contains('OFFICIAL') ?? false;
|
||||
|
||||
static void clear() {
|
||||
_nameCache.clear();
|
||||
_avatarCache.clear();
|
||||
_optionsCache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class TranscriptionResult {
|
||||
@@ -53,6 +59,8 @@ class TranscriptionCache {
|
||||
static TranscriptionResult? get(String messageId) => _cache[messageId];
|
||||
|
||||
static bool has(String messageId) => _cache.containsKey(messageId);
|
||||
|
||||
static void clear() => _cache.clear();
|
||||
}
|
||||
|
||||
class FileHistoryEntry {
|
||||
|
||||
Reference in New Issue
Block a user