ПИДОРАСЫ ЕБАНЫЕ Я ВАШ РОТ НАХУЙ СДЕЛАЮ УДАЛИТИ ГРУПА ПИДАРАСЫ КАКОГА ХУЯ ДЛЯ ИЗМЕНЕНЕЯ СПУФА НАДА ПЕРЕЗАХАДИТЬ ПИТАРАСЫ Я ВАШ РОТ НООБОРОТ

This commit is contained in:
jganenok
2025-11-20 10:05:22 +07:00
parent 15440536b4
commit b8b29b547f
6 changed files with 36 additions and 99 deletions

View File

@@ -170,15 +170,14 @@ extension ApiServiceChats on ApiService {
}; };
_lastChatsPayload = result; _lastChatsPayload = result;
final contacts = final contacts = contactListJson
contactListJson.map((json) => Contact.fromJson(json)).toList(); .map((json) => Contact.fromJson(json))
.toList();
updateContactCache(contacts); updateContactCache(contacts);
_lastChatsAt = DateTime.now(); _lastChatsAt = DateTime.now();
_preloadContactAvatars(contacts); _preloadContactAvatars(contacts);
unawaited( unawaited(
_chatCacheService.cacheChats( _chatCacheService.cacheChats(chatListJson.cast<Map<String, dynamic>>()),
chatListJson.cast<Map<String, dynamic>>(),
),
); );
unawaited(_chatCacheService.cacheContacts(contacts)); unawaited(_chatCacheService.cacheContacts(contacts));
return result; return result;
@@ -204,9 +203,7 @@ extension ApiServiceChats on ApiService {
} }
} }
if (!force && if (!force && !_chatsFetchedInThisSession && _lastChatsPayload == null) {
!_chatsFetchedInThisSession &&
_lastChatsPayload == null) {
final cachedChats = await _chatCacheService.getCachedChats(); final cachedChats = await _chatCacheService.getCachedChats();
final cachedContacts = await _chatCacheService.getCachedContacts(); final cachedContacts = await _chatCacheService.getCachedContacts();
if (cachedChats != null && if (cachedChats != null &&
@@ -393,15 +390,14 @@ extension ApiServiceChats on ApiService {
}; };
_lastChatsPayload = result; _lastChatsPayload = result;
final contacts = final contacts = contactListJson
contactListJson.map((json) => Contact.fromJson(json)).toList(); .map((json) => Contact.fromJson(json))
.toList();
updateContactCache(contacts); updateContactCache(contacts);
_lastChatsAt = DateTime.now(); _lastChatsAt = DateTime.now();
_preloadContactAvatars(contacts); _preloadContactAvatars(contacts);
unawaited( unawaited(
_chatCacheService.cacheChats( _chatCacheService.cacheChats(chatListJson.cast<Map<String, dynamic>>()),
chatListJson.cast<Map<String, dynamic>>(),
),
); );
unawaited(_chatCacheService.cacheContacts(contacts)); unawaited(_chatCacheService.cacheContacts(contacts));
_chatsFetchedInThisSession = true; _chatsFetchedInThisSession = true;
@@ -461,10 +457,13 @@ extension ApiServiceChats on ApiService {
} }
if (!force) { if (!force) {
final cachedMessages = final cachedMessages = await _chatCacheService.getCachedChatMessages(
await _chatCacheService.getCachedChatMessages(chatId); chatId,
);
if (cachedMessages != null && cachedMessages.isNotEmpty) { if (cachedMessages != null && cachedMessages.isNotEmpty) {
print("История сообщений для чата $chatId загружена из ChatCacheService."); print(
"История сообщений для чата $chatId загружена из ChatCacheService.",
);
_messageCache[chatId] = cachedMessages; _messageCache[chatId] = cachedMessages;
return cachedMessages; return cachedMessages;
} }
@@ -670,8 +669,7 @@ extension ApiServiceChats on ApiService {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final totalTraffic = final totalTraffic =
prefs.getDouble('network_total_traffic') ?? prefs.getDouble('network_total_traffic') ?? (150.0 * 1024 * 1024);
(150.0 * 1024 * 1024);
final messagesTraffic = final messagesTraffic =
prefs.getDouble('network_messages_traffic') ?? (totalTraffic * 0.15); prefs.getDouble('network_messages_traffic') ?? (totalTraffic * 0.15);
final mediaTraffic = final mediaTraffic =
@@ -679,8 +677,7 @@ extension ApiServiceChats on ApiService {
final syncTraffic = final syncTraffic =
prefs.getDouble('network_sync_traffic') ?? (totalTraffic * 0.1); prefs.getDouble('network_sync_traffic') ?? (totalTraffic * 0.1);
final currentSpeed = final currentSpeed = _isSessionOnline ? 512.0 * 1024 : 0.0;
_isSessionOnline ? 512.0 * 1024 : 0.0;
final ping = 25; final ping = 25;
@@ -1015,4 +1012,3 @@ extension ApiServiceChats on ApiService {
} }
} }
} }

View File

@@ -313,4 +313,3 @@ extension ApiServiceContacts on ApiService {
} }
} }
} }

View File

@@ -24,19 +24,13 @@ class Message {
}); });
factory Message.fromJson(Map<String, dynamic> json) { factory Message.fromJson(Map<String, dynamic> json) {
int senderId; int senderId;
if (json['sender'] is int) { if (json['sender'] is int) {
senderId = json['sender']; senderId = json['sender'];
} else { } else {
senderId = 0; senderId = 0;
} }
int time; int time;
if (json['time'] is int) { if (json['time'] is int) {
time = json['time']; time = json['time'];
@@ -45,7 +39,6 @@ class Message {
} }
return Message( return Message(
id: id:
json['id']?.toString() ?? json['id']?.toString() ??
'local_${DateTime.now().millisecondsSinceEpoch}', 'local_${DateTime.now().millisecondsSinceEpoch}',
@@ -96,11 +89,6 @@ class Message {
bool get isReply => link != null && link!['type'] == 'REPLY'; bool get isReply => link != null && link!['type'] == 'REPLY';
bool get isForwarded => link != null && link!['type'] == 'FORWARD'; bool get isForwarded => link != null && link!['type'] == 'FORWARD';
bool canEdit(int currentUserId) { bool canEdit(int currentUserId) {
if (isDeleted) return false; if (isDeleted) return false;
if (senderId != currentUserId) return false; if (senderId != currentUserId) return false;
@@ -108,7 +96,6 @@ class Message {
return false; // Нельзя редактировать сообщения с вложениями return false; // Нельзя редактировать сообщения с вложениями
} }
final now = DateTime.now().millisecondsSinceEpoch; final now = DateTime.now().millisecondsSinceEpoch;
final messageTime = time; final messageTime = time;
final hoursSinceCreation = (now - messageTime) / (1000 * 60 * 60); final hoursSinceCreation = (now - messageTime) / (1000 * 60 * 60);

View File

@@ -9,12 +9,9 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:gwid/api/api_service.dart'; import 'package:gwid/api/api_service.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'package:gwid/device_presets.dart'; import 'package:gwid/device_presets.dart';
import 'package:gwid/phone_entry_screen.dart';
enum SpoofingMethod { partial, full } enum SpoofingMethod { partial, full }
enum PresetCategory { web, device } enum PresetCategory { web, device }
class SessionSpoofingScreen extends StatefulWidget { class SessionSpoofingScreen extends StatefulWidget {
@@ -48,7 +45,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
_loadInitialData(); _loadInitialData();
} }
Future<void> _loadInitialData() async { Future<void> _loadInitialData() async {
setState(() => _isLoading = true); setState(() => _isLoading = true);
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
@@ -81,7 +77,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
setState(() => _isLoading = false); setState(() => _isLoading = false);
} }
Future<void> _loadDeviceData() async { Future<void> _loadDeviceData() async {
setState(() => _isLoading = true); setState(() => _isLoading = true);
@@ -129,7 +124,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
}); });
} }
Future<void> _applyGeneratedData() async { Future<void> _applyGeneratedData() async {
final List<DevicePreset> filteredPresets; final List<DevicePreset> filteredPresets;
if (_selectedCategory == PresetCategory.web) { if (_selectedCategory == PresetCategory.web) {
@@ -157,7 +151,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
await _applyPreset(preset); await _applyPreset(preset);
} }
Future<void> _applyPreset(DevicePreset preset) async { Future<void> _applyPreset(DevicePreset preset) async {
setState(() { setState(() {
_userAgentController.text = preset.userAgent; _userAgentController.text = preset.userAgent;
@@ -195,13 +188,11 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
} }
} }
Future<void> _saveSpoofingSettings() async { Future<void> _saveSpoofingSettings() async {
if (!mounted) return; if (!mounted) return;
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
final oldValues = { final oldValues = {
'user_agent': prefs.getString('spoof_useragent') ?? '', 'user_agent': prefs.getString('spoof_useragent') ?? '',
'device_name': prefs.getString('spoof_devicename') ?? '', '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 oldAppVersion = prefs.getString('spoof_appversion') ?? '25.10.10';
final newAppVersion = _appVersionController.text; final newAppVersion = _appVersionController.text;
bool otherDataChanged = false; bool otherDataChanged = false;
for (final key in oldValues.keys) { for (final key in oldValues.keys) {
if (oldValues[key] != newValues[key]) { if (oldValues[key] != newValues[key]) {
@@ -238,43 +228,33 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
final appVersionChanged = oldAppVersion != newAppVersion; final appVersionChanged = oldAppVersion != newAppVersion;
if (appVersionChanged && !otherDataChanged) { if (appVersionChanged && !otherDataChanged) {
await _saveAllData(prefs); await _saveAllData(prefs);
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( const SnackBar(
content: Text( content: Text('Перезайди!'),
'Настройки применятся при следующем входе в приложение.',
),
duration: Duration(seconds: 3), duration: Duration(seconds: 3),
), ),
); );
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} } else {
else {
final confirmed = await showDialog<bool>( final confirmed = await showDialog<bool>(
context: context, context: context,
builder: (context) => AlertDialog( builder: (context) => AlertDialog(
title: const Text('Применить настройки?'), title: const Text('Применить настройки?'),
content: const Text( content: const Text('Нужно перезайти в приложение, ок?'),
'Для применения настроек потребуется перезайти в аккаунт. Вы уверены?',
),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => Navigator.of(context).pop(false), onPressed: () => Navigator.of(context).pop(false),
child: const Text('Отмена'), child: const Text('Не'),
), ),
FilledButton( FilledButton(
onPressed: () => Navigator.of(context).pop(true), onPressed: () => Navigator.of(context).pop(true),
child: const Text('Применить'), child: const Text('Ок!'),
), ),
], ],
), ),
@@ -285,17 +265,23 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
await _saveAllData(prefs); await _saveAllData(prefs);
try { try {
await ApiService.instance.performFullReconnection();
if (mounted) { if (mounted) {
Navigator.of(context).pushAndRemoveUntil( ScaffoldMessenger.of(context).showSnackBar(
MaterialPageRoute(builder: (context) => const PhoneEntryScreen()), const SnackBar(
(route) => false, content: Text('Настройки применены. Перезайдите в приложение.'),
backgroundColor: Colors.green,
),
); );
Navigator.of(context).pop();
} }
} catch (e) { } catch (e) {
if (mounted) { if (mounted) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text('Ошибка при выходе: $e'), content: Text('Ошибка при применении настроек: $e'),
backgroundColor: Theme.of(context).colorScheme.error, backgroundColor: Theme.of(context).colorScheme.error,
), ),
); );
@@ -304,7 +290,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
} }
} }
Future<void> _saveAllData(SharedPreferences prefs) async { Future<void> _saveAllData(SharedPreferences prefs) async {
await prefs.setBool('spoofing_enabled', true); await prefs.setBool('spoofing_enabled', true);
await prefs.setString('spoof_useragent', _userAgentController.text); await prefs.setString('spoof_useragent', _userAgentController.text);
@@ -376,7 +361,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
body: _isLoading body: _isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: SingleChildScrollView( : SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 120), padding: const EdgeInsets.fromLTRB(16, 8, 16, 120),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -651,10 +635,8 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
'Версия приложения', 'Версия приложения',
Icons.info_outline_rounded, Icons.info_outline_rounded,
).copyWith( ).copyWith(
suffixIcon: _isCheckingVersion suffixIcon: _isCheckingVersion
? const Padding( ? const Padding(
padding: EdgeInsets.all(12.0), padding: EdgeInsets.all(12.0),
child: SizedBox( child: SizedBox(
height: 24, height: 24,
@@ -665,7 +647,6 @@ class _SessionSpoofingScreenState extends State<SessionSpoofingScreen> {
), ),
) )
: IconButton( : IconButton(
icon: const Icon(Icons.cloud_sync_outlined), icon: const Icon(Icons.cloud_sync_outlined),
tooltip: 'Проверить последнюю версию', tooltip: 'Проверить последнюю версию',
onPressed: onPressed:

View File

@@ -1,5 +1,3 @@
import 'dart:async'; import 'dart:async';
import 'package:gwid/models/contact.dart'; import 'package:gwid/models/contact.dart';
import 'package:gwid/models/message.dart'; import 'package:gwid/models/message.dart';
@@ -12,24 +10,20 @@ class ChatCacheService {
final CacheService _cacheService = CacheService(); final CacheService _cacheService = CacheService();
Future<void> initialize() async { Future<void> initialize() async {
await _cacheService.initialize(); await _cacheService.initialize();
print('ChatCacheService инициализирован'); print('ChatCacheService инициализирован');
} }
static const String _chatsKey = 'cached_chats'; static const String _chatsKey = 'cached_chats';
static const String _contactsKey = 'cached_contacts'; static const String _contactsKey = 'cached_contacts';
static const String _messagesKey = 'cached_messages'; static const String _messagesKey = 'cached_messages';
static const String _chatMessagesKey = 'cached_chat_messages'; static const String _chatMessagesKey = 'cached_chat_messages';
static const Duration _chatsTTL = Duration(hours: 1); static const Duration _chatsTTL = Duration(hours: 1);
static const Duration _contactsTTL = Duration(hours: 6); static const Duration _contactsTTL = Duration(hours: 6);
static const Duration _messagesTTL = Duration(hours: 2); static const Duration _messagesTTL = Duration(hours: 2);
Future<void> cacheChats(List<Map<String, dynamic>> chats) async { Future<void> cacheChats(List<Map<String, dynamic>> chats) async {
try { try {
await _cacheService.set(_chatsKey, chats, ttl: _chatsTTL); await _cacheService.set(_chatsKey, chats, ttl: _chatsTTL);
@@ -39,7 +33,6 @@ class ChatCacheService {
} }
} }
Future<List<Map<String, dynamic>>?> getCachedChats() async { Future<List<Map<String, dynamic>>?> getCachedChats() async {
try { try {
final cached = await _cacheService.get<List<dynamic>>( final cached = await _cacheService.get<List<dynamic>>(
@@ -55,7 +48,6 @@ class ChatCacheService {
return null; return null;
} }
Future<void> cacheContacts(List<Contact> contacts) async { Future<void> cacheContacts(List<Contact> contacts) async {
try { try {
final contactsData = contacts final contactsData = contacts
@@ -81,7 +73,6 @@ class ChatCacheService {
} }
} }
Future<List<Contact>?> getCachedContacts() async { Future<List<Contact>?> getCachedContacts() async {
try { try {
final cached = await _cacheService.get<List<dynamic>>( final cached = await _cacheService.get<List<dynamic>>(
@@ -97,7 +88,6 @@ class ChatCacheService {
return null; return null;
} }
Future<void> cacheChatMessages(int chatId, List<Message> messages) async { Future<void> cacheChatMessages(int chatId, List<Message> messages) async {
try { try {
final key = '$_chatMessagesKey$chatId'; final key = '$_chatMessagesKey$chatId';
@@ -125,7 +115,6 @@ class ChatCacheService {
} }
} }
Future<List<Message>?> getCachedChatMessages(int chatId) async { Future<List<Message>?> getCachedChatMessages(int chatId) async {
try { try {
final key = '$_chatMessagesKey$chatId'; final key = '$_chatMessagesKey$chatId';
@@ -142,17 +131,14 @@ class ChatCacheService {
return null; return null;
} }
Future<void> addMessageToCache(int chatId, Message message) async { Future<void> addMessageToCache(int chatId, Message message) async {
try { try {
final cached = await getCachedChatMessages(chatId); final cached = await getCachedChatMessages(chatId);
if (cached != null) { if (cached != null) {
final updatedMessages = [message, ...cached]; final updatedMessages = [message, ...cached];
await cacheChatMessages(chatId, updatedMessages); await cacheChatMessages(chatId, updatedMessages);
} else { } else {
await cacheChatMessages(chatId, [message]); await cacheChatMessages(chatId, [message]);
} }
} catch (e) { } catch (e) {
@@ -160,7 +146,6 @@ class ChatCacheService {
} }
} }
Future<void> updateMessageInCache(int chatId, Message updatedMessage) async { Future<void> updateMessageInCache(int chatId, Message updatedMessage) async {
try { try {
final cached = await getCachedChatMessages(chatId); final cached = await getCachedChatMessages(chatId);
@@ -180,7 +165,6 @@ class ChatCacheService {
} }
} }
Future<void> removeMessageFromCache(int chatId, String messageId) async { Future<void> removeMessageFromCache(int chatId, String messageId) async {
try { try {
final cached = await getCachedChatMessages(chatId); final cached = await getCachedChatMessages(chatId);
@@ -196,7 +180,6 @@ class ChatCacheService {
} }
} }
Future<void> cacheChatInfo(int chatId, Map<String, dynamic> chatInfo) async { Future<void> cacheChatInfo(int chatId, Map<String, dynamic> chatInfo) async {
try { try {
final key = 'chat_info_$chatId'; final key = 'chat_info_$chatId';
@@ -206,7 +189,6 @@ class ChatCacheService {
} }
} }
Future<Map<String, dynamic>?> getCachedChatInfo(int chatId) async { Future<Map<String, dynamic>?> getCachedChatInfo(int chatId) async {
try { try {
final key = 'chat_info_$chatId'; final key = 'chat_info_$chatId';
@@ -217,7 +199,6 @@ class ChatCacheService {
} }
} }
Future<void> cacheLastMessage(int chatId, Message? lastMessage) async { Future<void> cacheLastMessage(int chatId, Message? lastMessage) async {
try { try {
final key = 'last_message_$chatId'; final key = 'last_message_$chatId';
@@ -243,7 +224,6 @@ class ChatCacheService {
} }
} }
Future<Message?> getCachedLastMessage(int chatId) async { Future<Message?> getCachedLastMessage(int chatId) async {
try { try {
final key = 'last_message_$chatId'; final key = 'last_message_$chatId';
@@ -262,7 +242,6 @@ class ChatCacheService {
return null; return null;
} }
Future<void> clearChatCache(int chatId) async { Future<void> clearChatCache(int chatId) async {
try { try {
final keys = [ final keys = [
@@ -281,22 +260,18 @@ class ChatCacheService {
} }
} }
Future<void> clearAllChatCache() async { Future<void> clearAllChatCache() async {
try { try {
await _cacheService.remove(_chatsKey); await _cacheService.remove(_chatsKey);
await _cacheService.remove(_contactsKey); await _cacheService.remove(_contactsKey);
await _cacheService.remove(_messagesKey); await _cacheService.remove(_messagesKey);
print('Весь кэш чатов очищен'); print('Весь кэш чатов очищен');
} catch (e) { } catch (e) {
print('Ошибка очистки всего кэша чатов: $e'); print('Ошибка очистки всего кэша чатов: $e');
} }
} }
Future<Map<String, dynamic>> getChatCacheStats() async { Future<Map<String, dynamic>> getChatCacheStats() async {
try { try {
final cacheStats = await _cacheService.getCacheStats(); final cacheStats = await _cacheService.getCacheStats();
@@ -314,7 +289,6 @@ class ChatCacheService {
} }
} }
Future<bool> isCacheValid(String cacheType) async { Future<bool> isCacheValid(String cacheType) async {
try { try {
switch (cacheType) { switch (cacheType) {

View File

@@ -809,10 +809,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.16.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@@ -1318,10 +1318,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.7" version: "0.7.6"
timezone: timezone:
dependency: "direct main" dependency: "direct main"
description: description: