ПИДОРАСЫ ЕБАНЫЕ Я ВАШ РОТ НАХУЙ СДЕЛАЮ УДАЛИТИ ГРУПА ПИДАРАСЫ КАКОГА ХУЯ ДЛЯ ИЗМЕНЕНЕЯ СПУФА НАДА ПЕРЕЗАХАДИТЬ ПИТАРАСЫ Я ВАШ РОТ НООБОРОТ
This commit is contained in:
@@ -170,15 +170,14 @@ extension ApiServiceChats on ApiService {
|
||||
};
|
||||
_lastChatsPayload = result;
|
||||
|
||||
final contacts =
|
||||
contactListJson.map((json) => Contact.fromJson(json)).toList();
|
||||
final contacts = contactListJson
|
||||
.map((json) => Contact.fromJson(json))
|
||||
.toList();
|
||||
updateContactCache(contacts);
|
||||
_lastChatsAt = DateTime.now();
|
||||
_preloadContactAvatars(contacts);
|
||||
unawaited(
|
||||
_chatCacheService.cacheChats(
|
||||
chatListJson.cast<Map<String, dynamic>>(),
|
||||
),
|
||||
_chatCacheService.cacheChats(chatListJson.cast<Map<String, dynamic>>()),
|
||||
);
|
||||
unawaited(_chatCacheService.cacheContacts(contacts));
|
||||
return result;
|
||||
@@ -204,9 +203,7 @@ extension ApiServiceChats on ApiService {
|
||||
}
|
||||
}
|
||||
|
||||
if (!force &&
|
||||
!_chatsFetchedInThisSession &&
|
||||
_lastChatsPayload == null) {
|
||||
if (!force && !_chatsFetchedInThisSession && _lastChatsPayload == null) {
|
||||
final cachedChats = await _chatCacheService.getCachedChats();
|
||||
final cachedContacts = await _chatCacheService.getCachedContacts();
|
||||
if (cachedChats != null &&
|
||||
@@ -393,15 +390,14 @@ extension ApiServiceChats on ApiService {
|
||||
};
|
||||
_lastChatsPayload = result;
|
||||
|
||||
final contacts =
|
||||
contactListJson.map((json) => Contact.fromJson(json)).toList();
|
||||
final contacts = contactListJson
|
||||
.map((json) => Contact.fromJson(json))
|
||||
.toList();
|
||||
updateContactCache(contacts);
|
||||
_lastChatsAt = DateTime.now();
|
||||
_preloadContactAvatars(contacts);
|
||||
unawaited(
|
||||
_chatCacheService.cacheChats(
|
||||
chatListJson.cast<Map<String, dynamic>>(),
|
||||
),
|
||||
_chatCacheService.cacheChats(chatListJson.cast<Map<String, dynamic>>()),
|
||||
);
|
||||
unawaited(_chatCacheService.cacheContacts(contacts));
|
||||
_chatsFetchedInThisSession = true;
|
||||
@@ -461,10 +457,13 @@ extension ApiServiceChats on ApiService {
|
||||
}
|
||||
|
||||
if (!force) {
|
||||
final cachedMessages =
|
||||
await _chatCacheService.getCachedChatMessages(chatId);
|
||||
final cachedMessages = await _chatCacheService.getCachedChatMessages(
|
||||
chatId,
|
||||
);
|
||||
if (cachedMessages != null && cachedMessages.isNotEmpty) {
|
||||
print("История сообщений для чата $chatId загружена из ChatCacheService.");
|
||||
print(
|
||||
"История сообщений для чата $chatId загружена из ChatCacheService.",
|
||||
);
|
||||
_messageCache[chatId] = cachedMessages;
|
||||
return cachedMessages;
|
||||
}
|
||||
@@ -670,8 +669,7 @@ extension ApiServiceChats on ApiService {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
final totalTraffic =
|
||||
prefs.getDouble('network_total_traffic') ??
|
||||
(150.0 * 1024 * 1024);
|
||||
prefs.getDouble('network_total_traffic') ?? (150.0 * 1024 * 1024);
|
||||
final messagesTraffic =
|
||||
prefs.getDouble('network_messages_traffic') ?? (totalTraffic * 0.15);
|
||||
final mediaTraffic =
|
||||
@@ -679,8 +677,7 @@ extension ApiServiceChats on ApiService {
|
||||
final syncTraffic =
|
||||
prefs.getDouble('network_sync_traffic') ?? (totalTraffic * 0.1);
|
||||
|
||||
final currentSpeed =
|
||||
_isSessionOnline ? 512.0 * 1024 : 0.0;
|
||||
final currentSpeed = _isSessionOnline ? 512.0 * 1024 : 0.0;
|
||||
|
||||
final ping = 25;
|
||||
|
||||
@@ -1015,4 +1012,3 @@ extension ApiServiceChats on ApiService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -313,4 +313,3 @@ extension ApiServiceContacts on ApiService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,19 +24,13 @@ class Message {
|
||||
});
|
||||
|
||||
factory Message.fromJson(Map<String, dynamic> json) {
|
||||
|
||||
|
||||
|
||||
|
||||
int senderId;
|
||||
if (json['sender'] is int) {
|
||||
senderId = json['sender'];
|
||||
} else {
|
||||
|
||||
senderId = 0;
|
||||
}
|
||||
|
||||
|
||||
int time;
|
||||
if (json['time'] is int) {
|
||||
time = json['time'];
|
||||
@@ -45,7 +39,6 @@ class Message {
|
||||
}
|
||||
|
||||
return Message(
|
||||
|
||||
id:
|
||||
json['id']?.toString() ??
|
||||
'local_${DateTime.now().millisecondsSinceEpoch}',
|
||||
@@ -96,11 +89,6 @@ class Message {
|
||||
bool get isReply => link != null && link!['type'] == 'REPLY';
|
||||
bool get isForwarded => link != null && link!['type'] == 'FORWARD';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool canEdit(int currentUserId) {
|
||||
if (isDeleted) return false;
|
||||
if (senderId != currentUserId) return false;
|
||||
@@ -108,7 +96,6 @@ class Message {
|
||||
return false; // Нельзя редактировать сообщения с вложениями
|
||||
}
|
||||
|
||||
|
||||
final now = DateTime.now().millisecondsSinceEpoch;
|
||||
final messageTime = time;
|
||||
final hoursSinceCreation = (now - messageTime) / (1000 * 60 * 60);
|
||||
|
||||
@@ -9,12 +9,9 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:gwid/api/api_service.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import 'package:gwid/device_presets.dart';
|
||||
import 'package:gwid/phone_entry_screen.dart';
|
||||
|
||||
|
||||
enum SpoofingMethod { partial, full }
|
||||
|
||||
|
||||
enum PresetCategory { web, device }
|
||||
|
||||
class SessionSpoofingScreen extends StatefulWidget {
|
||||
@@ -48,7 +45,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
_loadInitialData();
|
||||
}
|
||||
|
||||
|
||||
Future<void> _loadInitialData() async {
|
||||
setState(() => _isLoading = true);
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@@ -81,7 +77,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
|
||||
|
||||
Future<void> _loadDeviceData() async {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
@@ -129,7 +124,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Future<void> _applyGeneratedData() async {
|
||||
final List<DevicePreset> filteredPresets;
|
||||
if (_selectedCategory == PresetCategory.web) {
|
||||
@@ -157,7 +151,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
await _applyPreset(preset);
|
||||
}
|
||||
|
||||
|
||||
Future<void> _applyPreset(DevicePreset preset) async {
|
||||
setState(() {
|
||||
_userAgentController.text = preset.userAgent;
|
||||
@@ -195,13 +188,11 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _saveSpoofingSettings() async {
|
||||
if (!mounted) return;
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
|
||||
final oldValues = {
|
||||
'user_agent': prefs.getString('spoof_useragent') ?? '',
|
||||
'device_name': prefs.getString('spoof_devicename') ?? '',
|
||||
@@ -227,7 +218,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
final oldAppVersion = prefs.getString('spoof_appversion') ?? '25.10.10';
|
||||
final newAppVersion = _appVersionController.text;
|
||||
|
||||
|
||||
bool otherDataChanged = false;
|
||||
for (final key in oldValues.keys) {
|
||||
if (oldValues[key] != newValues[key]) {
|
||||
@@ -238,43 +228,33 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
|
||||
final appVersionChanged = oldAppVersion != newAppVersion;
|
||||
|
||||
|
||||
|
||||
|
||||
if (appVersionChanged && !otherDataChanged) {
|
||||
|
||||
await _saveAllData(prefs);
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text(
|
||||
'Настройки применятся при следующем входе в приложение.',
|
||||
),
|
||||
content: Text('Перезайди!'),
|
||||
duration: Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Применить настройки?'),
|
||||
content: const Text(
|
||||
'Для применения настроек потребуется перезайти в аккаунт. Вы уверены?',
|
||||
),
|
||||
content: const Text('Нужно перезайти в приложение, ок?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Отмена'),
|
||||
child: const Text('Не'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text('Применить'),
|
||||
child: const Text('Ок!'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -285,17 +265,23 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
await _saveAllData(prefs);
|
||||
|
||||
try {
|
||||
await ApiService.instance.performFullReconnection();
|
||||
|
||||
if (mounted) {
|
||||
Navigator.of(context).pushAndRemoveUntil(
|
||||
MaterialPageRoute(builder: (context) => const PhoneEntryScreen()),
|
||||
(route) => false,
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Настройки применены. Перезайдите в приложение.'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Ошибка при выходе: $e'),
|
||||
content: Text('Ошибка при применении настроек: $e'),
|
||||
backgroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
);
|
||||
@@ -304,7 +290,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> _saveAllData(SharedPreferences prefs) async {
|
||||
await prefs.setBool('spoofing_enabled', true);
|
||||
await prefs.setString('spoof_useragent', _userAgentController.text);
|
||||
@@ -376,7 +361,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
body: _isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: SingleChildScrollView(
|
||||
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 120),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -651,10 +635,8 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
'Версия приложения',
|
||||
Icons.info_outline_rounded,
|
||||
).copyWith(
|
||||
|
||||
suffixIcon: _isCheckingVersion
|
||||
? const Padding(
|
||||
|
||||
padding: EdgeInsets.all(12.0),
|
||||
child: SizedBox(
|
||||
height: 24,
|
||||
@@ -665,7 +647,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
|
||||
icon: const Icon(Icons.cloud_sync_outlined),
|
||||
tooltip: 'Проверить последнюю версию',
|
||||
onPressed:
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:gwid/models/contact.dart';
|
||||
import 'package:gwid/models/message.dart';
|
||||
@@ -12,24 +10,20 @@ class ChatCacheService {
|
||||
|
||||
final CacheService _cacheService = CacheService();
|
||||
|
||||
|
||||
Future<void> initialize() async {
|
||||
await _cacheService.initialize();
|
||||
print('ChatCacheService инициализирован');
|
||||
}
|
||||
|
||||
|
||||
static const String _chatsKey = 'cached_chats';
|
||||
static const String _contactsKey = 'cached_contacts';
|
||||
static const String _messagesKey = 'cached_messages';
|
||||
static const String _chatMessagesKey = 'cached_chat_messages';
|
||||
|
||||
|
||||
static const Duration _chatsTTL = Duration(hours: 1);
|
||||
static const Duration _contactsTTL = Duration(hours: 6);
|
||||
static const Duration _messagesTTL = Duration(hours: 2);
|
||||
|
||||
|
||||
Future<void> cacheChats(List<Map<String, dynamic>> chats) async {
|
||||
try {
|
||||
await _cacheService.set(_chatsKey, chats, ttl: _chatsTTL);
|
||||
@@ -39,7 +33,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Map<String, dynamic>>?> getCachedChats() async {
|
||||
try {
|
||||
final cached = await _cacheService.get<List<dynamic>>(
|
||||
@@ -55,7 +48,6 @@ class ChatCacheService {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> cacheContacts(List<Contact> contacts) async {
|
||||
try {
|
||||
final contactsData = contacts
|
||||
@@ -81,7 +73,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Contact>?> getCachedContacts() async {
|
||||
try {
|
||||
final cached = await _cacheService.get<List<dynamic>>(
|
||||
@@ -97,7 +88,6 @@ class ChatCacheService {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> cacheChatMessages(int chatId, List<Message> messages) async {
|
||||
try {
|
||||
final key = '$_chatMessagesKey$chatId';
|
||||
@@ -125,7 +115,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<List<Message>?> getCachedChatMessages(int chatId) async {
|
||||
try {
|
||||
final key = '$_chatMessagesKey$chatId';
|
||||
@@ -142,17 +131,14 @@ class ChatCacheService {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> addMessageToCache(int chatId, Message message) async {
|
||||
try {
|
||||
final cached = await getCachedChatMessages(chatId);
|
||||
|
||||
if (cached != null) {
|
||||
|
||||
final updatedMessages = [message, ...cached];
|
||||
await cacheChatMessages(chatId, updatedMessages);
|
||||
} else {
|
||||
|
||||
await cacheChatMessages(chatId, [message]);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -160,7 +146,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> updateMessageInCache(int chatId, Message updatedMessage) async {
|
||||
try {
|
||||
final cached = await getCachedChatMessages(chatId);
|
||||
@@ -180,7 +165,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> removeMessageFromCache(int chatId, String messageId) async {
|
||||
try {
|
||||
final cached = await getCachedChatMessages(chatId);
|
||||
@@ -196,7 +180,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> cacheChatInfo(int chatId, Map<String, dynamic> chatInfo) async {
|
||||
try {
|
||||
final key = 'chat_info_$chatId';
|
||||
@@ -206,7 +189,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>?> getCachedChatInfo(int chatId) async {
|
||||
try {
|
||||
final key = 'chat_info_$chatId';
|
||||
@@ -217,7 +199,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> cacheLastMessage(int chatId, Message? lastMessage) async {
|
||||
try {
|
||||
final key = 'last_message_$chatId';
|
||||
@@ -243,7 +224,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Message?> getCachedLastMessage(int chatId) async {
|
||||
try {
|
||||
final key = 'last_message_$chatId';
|
||||
@@ -262,7 +242,6 @@ class ChatCacheService {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Future<void> clearChatCache(int chatId) async {
|
||||
try {
|
||||
final keys = [
|
||||
@@ -281,22 +260,18 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<void> clearAllChatCache() async {
|
||||
try {
|
||||
await _cacheService.remove(_chatsKey);
|
||||
await _cacheService.remove(_contactsKey);
|
||||
await _cacheService.remove(_messagesKey);
|
||||
|
||||
|
||||
|
||||
print('Весь кэш чатов очищен');
|
||||
} catch (e) {
|
||||
print('Ошибка очистки всего кэша чатов: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> getChatCacheStats() async {
|
||||
try {
|
||||
final cacheStats = await _cacheService.getCacheStats();
|
||||
@@ -314,7 +289,6 @@ class ChatCacheService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<bool> isCacheValid(String cacheType) async {
|
||||
try {
|
||||
switch (cacheType) {
|
||||
|
||||
@@ -809,10 +809,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.16.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1318,10 +1318,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
|
||||
sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.7"
|
||||
version: "0.7.6"
|
||||
timezone:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user