добавил норм настройки приватности, в третий блять раз
This commit is contained in:
@@ -979,6 +979,10 @@ class ApiService {
|
|||||||
chatResponse['payload']?['chats'] ?? [];
|
chatResponse['payload']?['chats'] ?? [];
|
||||||
|
|
||||||
if (chatListJson.isEmpty) {
|
if (chatListJson.isEmpty) {
|
||||||
|
if (config != null) {
|
||||||
|
_processServerPrivacyConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
final result = {
|
final result = {
|
||||||
'chats': [],
|
'chats': [],
|
||||||
'contacts': [],
|
'contacts': [],
|
||||||
@@ -1013,6 +1017,10 @@ class ApiService {
|
|||||||
updatePresenceData(presence);
|
updatePresenceData(presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config != null) {
|
||||||
|
_processServerPrivacyConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
final result = {
|
final result = {
|
||||||
'chats': chatListJson,
|
'chats': chatListJson,
|
||||||
'contacts': contactListJson,
|
'contacts': contactListJson,
|
||||||
@@ -2564,27 +2572,28 @@ class ApiService {
|
|||||||
_lastChatsAt = null;
|
_lastChatsAt = null;
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"✅ Кэш чатов очищен: _lastChatsPayload = $_lastChatsPayload, _chatsFetchedInThisSession = $_chatsFetchedInThisSession",
|
" Кэш чатов очищен: _lastChatsPayload = $_lastChatsPayload, _chatsFetchedInThisSession = $_chatsFetchedInThisSession",
|
||||||
);
|
);
|
||||||
|
|
||||||
_connectionStatusController.add("disconnected");
|
_connectionStatusController.add("disconnected");
|
||||||
|
|
||||||
await connect();
|
await connect();
|
||||||
|
|
||||||
print("✅ Полное переподключение завершено");
|
print(" Полное переподключение завершено");
|
||||||
|
|
||||||
await Future.delayed(const Duration(milliseconds: 1500));
|
await Future.delayed(const Duration(milliseconds: 1500));
|
||||||
|
|
||||||
if (!_reconnectionCompleteController.isClosed) {
|
if (!_reconnectionCompleteController.isClosed) {
|
||||||
print("📢 Отправляем уведомление о завершении переподключения");
|
print(" Отправляем уведомление о завершении переподключения");
|
||||||
_reconnectionCompleteController.add(null);
|
_reconnectionCompleteController.add(null);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("❌ Ошибка полного переподключения: $e");
|
print("Ошибка полного переподключения: $e");
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ЫЫЫ ХУЯРЮ ВПЕРОД В БОГАЖНЕКЕ ГРАНАТАМЁТ
|
||||||
Future<void> updatePrivacySettings({
|
Future<void> updatePrivacySettings({
|
||||||
String? hidden,
|
String? hidden,
|
||||||
String? searchByPhone,
|
String? searchByPhone,
|
||||||
@@ -2595,6 +2604,7 @@ class ApiService {
|
|||||||
String? pushSound,
|
String? pushSound,
|
||||||
bool? mCallPushNotification,
|
bool? mCallPushNotification,
|
||||||
bool? pushDetails,
|
bool? pushDetails,
|
||||||
|
bool? contentLevelAccess,
|
||||||
}) async {
|
}) async {
|
||||||
final settings = {
|
final settings = {
|
||||||
if (hidden != null) 'user': {'HIDDEN': hidden == 'true'},
|
if (hidden != null) 'user': {'HIDDEN': hidden == 'true'},
|
||||||
@@ -2610,19 +2620,30 @@ class ApiService {
|
|||||||
if (pushDetails != null) 'user': {'PUSH_DETAILS': pushDetails},
|
if (pushDetails != null) 'user': {'PUSH_DETAILS': pushDetails},
|
||||||
};
|
};
|
||||||
|
|
||||||
print('Обновляем настройки приватности: $settings');
|
print(''); // КАК ЖЕ ПОХУЙ
|
||||||
|
|
||||||
if (hidden != null) {
|
if (hidden != null) {
|
||||||
await _updateSinglePrivacySetting({'HIDDEN': hidden == 'true'});
|
await _updateSinglePrivacySetting({'HIDDEN': hidden == 'true'});
|
||||||
}
|
}
|
||||||
if (searchByPhone != null) {
|
if (searchByPhone != null) {
|
||||||
await _updateSinglePrivacySetting({'SEARCH_BY_PHONE': searchByPhone});
|
final seq = searchByPhone == 'ALL' ? 37 : 46;
|
||||||
|
await _updatePrivacySettingWithSeq({
|
||||||
|
'SEARCH_BY_PHONE': searchByPhone,
|
||||||
|
}, seq);
|
||||||
}
|
}
|
||||||
if (incomingCall != null) {
|
if (incomingCall != null) {
|
||||||
await _updateSinglePrivacySetting({'INCOMING_CALL': incomingCall});
|
final seq = incomingCall == 'ALL' ? 30 : 23;
|
||||||
|
await _updatePrivacySettingWithSeq({'INCOMING_CALL': incomingCall}, seq);
|
||||||
}
|
}
|
||||||
if (chatsInvite != null) {
|
if (chatsInvite != null) {
|
||||||
await _updateSinglePrivacySetting({'CHATS_INVITE': chatsInvite});
|
final seq = chatsInvite == 'ALL' ? 51 : 55;
|
||||||
|
await _updatePrivacySettingWithSeq({'CHATS_INVITE': chatsInvite}, seq);
|
||||||
|
}
|
||||||
|
if (contentLevelAccess != null) {
|
||||||
|
final seq = contentLevelAccess ? 70 : 62;
|
||||||
|
await _updatePrivacySettingWithSeq({
|
||||||
|
'CONTENT_LEVEL_ACCESS': contentLevelAccess,
|
||||||
|
}, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatsPushNotification != null) {
|
if (chatsPushNotification != null) {
|
||||||
@@ -2647,10 +2668,77 @@ class ApiService {
|
|||||||
Future<void> _updateSinglePrivacySetting(Map<String, dynamic> setting) async {
|
Future<void> _updateSinglePrivacySetting(Map<String, dynamic> setting) async {
|
||||||
await waitUntilOnline();
|
await waitUntilOnline();
|
||||||
|
|
||||||
final payload = {'settings': setting};
|
final payload = {
|
||||||
|
'settings': {'user': setting},
|
||||||
|
};
|
||||||
|
|
||||||
_sendMessage(22, payload);
|
_sendMessage(22, payload);
|
||||||
print('Отправляем обновление настройки приватности: $payload');
|
print(''); //песюны
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _updatePrivacySettingWithSeq(
|
||||||
|
Map<String, dynamic> setting,
|
||||||
|
int seq,
|
||||||
|
) async {
|
||||||
|
await waitUntilOnline();
|
||||||
|
|
||||||
|
final message = {
|
||||||
|
"ver": 11,
|
||||||
|
"cmd": 0,
|
||||||
|
"seq": seq,
|
||||||
|
"opcode": 22,
|
||||||
|
"payload": {
|
||||||
|
"settings": {"user": setting},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
final encodedMessage = jsonEncode(message);
|
||||||
|
_channel?.sink.add(encodedMessage);
|
||||||
|
_log('SEND: $encodedMessage');
|
||||||
|
print(
|
||||||
|
'', //вроде надо а вроде бля как же похуй
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _processServerPrivacyConfig(Map<String, dynamic>? config) {
|
||||||
|
if (config == null) return;
|
||||||
|
|
||||||
|
final userConfig = config['user'] as Map<String, dynamic>?;
|
||||||
|
if (userConfig == null) return;
|
||||||
|
|
||||||
|
print('Обработка настроек приватности с сервера: $userConfig');
|
||||||
|
|
||||||
|
// Сохраняем настройки в SharedPreferences
|
||||||
|
final prefs = SharedPreferences.getInstance();
|
||||||
|
prefs.then((prefs) {
|
||||||
|
if (userConfig.containsKey('SEARCH_BY_PHONE')) {
|
||||||
|
prefs.setString(
|
||||||
|
'privacy_search_by_phone',
|
||||||
|
userConfig['SEARCH_BY_PHONE'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (userConfig.containsKey('INCOMING_CALL')) {
|
||||||
|
prefs.setString('privacy_incoming_call', userConfig['INCOMING_CALL']);
|
||||||
|
}
|
||||||
|
if (userConfig.containsKey('CHATS_INVITE')) {
|
||||||
|
prefs.setString('privacy_chats_invite', userConfig['CHATS_INVITE']);
|
||||||
|
}
|
||||||
|
if (userConfig.containsKey('CONTENT_LEVEL_ACCESS')) {
|
||||||
|
prefs.setBool(
|
||||||
|
'privacy_content_level_access',
|
||||||
|
userConfig['CONTENT_LEVEL_ACCESS'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (userConfig.containsKey('HIDDEN')) {
|
||||||
|
prefs.setBool('privacy_hidden', userConfig['HIDDEN']);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Отправляем событие об обновлении настроек
|
||||||
|
_messageController.add({
|
||||||
|
'type': 'privacy_settings_updated',
|
||||||
|
'settings': {'user': userConfig},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class _FullScreenVideoPlayerState extends State<FullScreenVideoPlayer> {
|
|||||||
_videoPlayerController = VideoPlayerController.networkUrl(
|
_videoPlayerController = VideoPlayerController.networkUrl(
|
||||||
Uri.parse(widget.videoUrl),
|
Uri.parse(widget.videoUrl),
|
||||||
httpHeaders: const {
|
httpHeaders: const {
|
||||||
|
|
||||||
'User-Agent':
|
'User-Agent':
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||||
},
|
},
|
||||||
@@ -49,7 +48,6 @@ class _FullScreenVideoPlayerState extends State<FullScreenVideoPlayer> {
|
|||||||
backgroundColor: Colors.grey,
|
backgroundColor: Colors.grey,
|
||||||
bufferedColor: Colors.white,
|
bufferedColor: Colors.white,
|
||||||
),
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gwid/api_service.dart';
|
import 'package:gwid/api_service.dart';
|
||||||
import 'package:gwid/theme_provider.dart';
|
import 'package:gwid/theme_provider.dart';
|
||||||
@@ -15,12 +13,12 @@ class PrivacySettingsScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
||||||
|
|
||||||
bool _isHidden = false;
|
bool _isHidden = false;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
String _searchByPhone = 'ALL'; // 'ALL', 'CONTACTS', 'NOBODY'
|
String _searchByPhone = 'ALL';
|
||||||
String _incomingCall = 'ALL'; // 'ALL', 'CONTACTS', 'NOBODY'
|
String _incomingCall = 'ALL';
|
||||||
String _chatsInvite = 'ALL'; // 'ALL', 'CONTACTS', 'NOBODY'
|
String _chatsInvite = 'ALL';
|
||||||
|
bool _contentLevelAccess = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -42,6 +40,8 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
_searchByPhone = prefs.getString('privacy_search_by_phone') ?? 'ALL';
|
_searchByPhone = prefs.getString('privacy_search_by_phone') ?? 'ALL';
|
||||||
_incomingCall = prefs.getString('privacy_incoming_call') ?? 'ALL';
|
_incomingCall = prefs.getString('privacy_incoming_call') ?? 'ALL';
|
||||||
_chatsInvite = prefs.getString('privacy_chats_invite') ?? 'ALL';
|
_chatsInvite = prefs.getString('privacy_chats_invite') ?? 'ALL';
|
||||||
|
_contentLevelAccess =
|
||||||
|
prefs.getBool('privacy_content_level_access') ?? false;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Ошибка загрузки настроек приватности: $e');
|
print('Ошибка загрузки настроек приватности: $e');
|
||||||
@@ -61,8 +61,6 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _updateHiddenStatus(bool hidden) async {
|
Future<void> _updateHiddenStatus(bool hidden) async {
|
||||||
setState(() => _isLoading = true);
|
setState(() => _isLoading = true);
|
||||||
try {
|
try {
|
||||||
@@ -92,12 +90,14 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
String? searchByPhone,
|
String? searchByPhone,
|
||||||
String? incomingCall,
|
String? incomingCall,
|
||||||
String? chatsInvite,
|
String? chatsInvite,
|
||||||
|
bool? contentLevelAccess,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
await ApiService.instance.updatePrivacySettings(
|
await ApiService.instance.updatePrivacySettings(
|
||||||
searchByPhone: searchByPhone,
|
searchByPhone: searchByPhone,
|
||||||
incomingCall: incomingCall,
|
incomingCall: incomingCall,
|
||||||
chatsInvite: chatsInvite,
|
chatsInvite: chatsInvite,
|
||||||
|
contentLevelAccess: contentLevelAccess,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (searchByPhone != null) {
|
if (searchByPhone != null) {
|
||||||
@@ -112,6 +112,13 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
await _savePrivacySetting('privacy_chats_invite', chatsInvite);
|
await _savePrivacySetting('privacy_chats_invite', chatsInvite);
|
||||||
if (mounted) setState(() => _chatsInvite = chatsInvite);
|
if (mounted) setState(() => _chatsInvite = chatsInvite);
|
||||||
}
|
}
|
||||||
|
if (contentLevelAccess != null) {
|
||||||
|
await _savePrivacySetting(
|
||||||
|
'privacy_content_level_access',
|
||||||
|
contentLevelAccess,
|
||||||
|
);
|
||||||
|
if (mounted) setState(() => _contentLevelAccess = contentLevelAccess);
|
||||||
|
}
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
@@ -137,8 +144,6 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _showOptionDialog(
|
void _showOptionDialog(
|
||||||
String title,
|
String title,
|
||||||
String currentValue,
|
String currentValue,
|
||||||
@@ -162,7 +167,6 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
currentValue,
|
currentValue,
|
||||||
onSelect,
|
onSelect,
|
||||||
),
|
),
|
||||||
_buildDialogOption('Никто', 'NOBODY', currentValue, onSelect),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -188,8 +192,6 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String _getPrivacyDescription(String value) {
|
String _getPrivacyDescription(String value) {
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case 'ALL':
|
case 'ALL':
|
||||||
@@ -313,6 +315,34 @@ class _PrivacySettingsScreenState extends State<PrivacySettingsScreen> {
|
|||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
_OutlinedSection(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildSectionTitle("Уровень контента", colors),
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: EdgeInsets.zero,
|
||||||
|
secondary: Icon(
|
||||||
|
_contentLevelAccess
|
||||||
|
? Icons.shield_outlined
|
||||||
|
: Icons.visibility_outlined,
|
||||||
|
),
|
||||||
|
title: const Text("Безопасный режим"),
|
||||||
|
subtitle: Text(
|
||||||
|
_contentLevelAccess
|
||||||
|
? "Показывать только безопасный контент"
|
||||||
|
: "Показывать весь доступный контент",
|
||||||
|
),
|
||||||
|
value: _contentLevelAccess,
|
||||||
|
onChanged: (value) =>
|
||||||
|
_updatePrivacyOption(contentLevelAccess: value),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
_OutlinedSection(
|
_OutlinedSection(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
Reference in New Issue
Block a user