fix: скрытие удаленных аккаунтов с контактов, возможно фикс скрытия медиа дорожки в кружках на кастомных android прошивках версии android ниже 16

This commit is contained in:
Jganenokk
2026-08-22 21:54:11 +07:00
parent 6dc1835377
commit 0091b5f272
9 changed files with 296 additions and 29 deletions
+129
View File
@@ -0,0 +1,129 @@
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
import 'package:komet/backend/modules/contacts.dart';
import 'package:komet/core/storage/app_database.dart';
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class _SyntheticPathProvider extends PathProviderPlatform
with MockPlatformInterfaceMixin {
final String directory;
_SyntheticPathProvider(this.directory);
@override
Future<String?> getApplicationSupportPath() async => directory;
}
Map<dynamic, dynamic> _serverContact({
required int id,
required String firstName,
required int phone,
int accountStatus = 0,
}) {
return {
'id': id,
'phone': phone,
'updateTime': 1,
'accountStatus': accountStatus,
'names': [
{'type': 'ONEME', 'firstName': firstName, 'lastName': 'Synthetic'},
],
};
}
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
const accountId = 1;
setUp(() async {
final directory = Directory.systemTemp.createTempSync(
'synthetic_contacts_deleted_test',
);
PathProviderPlatform.instance = _SyntheticPathProvider(directory.path);
addTearDown(() async {
await AppDatabase.close();
if (directory.existsSync()) directory.deleteSync(recursive: true);
});
await AppDatabase.init();
await AppDatabase.saveProfile(
ProfileData(
id: accountId,
firstName: 'Synthetic owner',
phone: 100000,
country: 'ZZ',
accountStatus: 0,
updateTime: 1,
),
);
await ContactsModule.syncFromLoginPayload({
'contacts': [
_serverContact(id: 11, firstName: 'Alive', phone: 700000011),
_serverContact(
id: 12,
firstName: 'Gone',
phone: 700000012,
accountStatus: 2,
),
],
}, accountId);
});
test('deleted accounts are hidden from the contact list', () async {
final visible = await ContactsModule.getContacts(accountId);
expect(visible.map((c) => c.id), [11]);
expect(visible.single.isDeleted, isFalse);
});
test('deleted accounts stay available when explicitly requested', () async {
final all = await ContactsModule.getContacts(
accountId,
includeDeleted: true,
);
expect(all.map((c) => c.id).toSet(), {11, 12});
expect(all.firstWhere((c) => c.id == 12).isDeleted, isTrue);
});
test(
'a re-synced deleted account does not come back into the list',
() async {
await ContactsModule.syncFromLoginPayload({
'contacts': [
_serverContact(
id: 12,
firstName: 'Gone',
phone: 700000012,
accountStatus: 2,
),
],
}, accountId);
final visible = await ContactsModule.getContacts(accountId);
expect(visible.map((c) => c.id), [11]);
},
);
test('a contact without accountStatus is treated as alive', () async {
await ContactsModule.syncFromLoginPayload({
'contacts': [
{
'id': 13,
'phone': 700000013,
'updateTime': 1,
'names': [
{'type': 'ONEME', 'firstName': 'Legacy', 'lastName': 'Synthetic'},
],
},
],
}, accountId);
final visible = await ContactsModule.getContacts(accountId);
expect(visible.map((c) => c.id).toSet(), {11, 13});
});
}
+45
View File
@@ -0,0 +1,45 @@
import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';
import 'package:komet/core/media/video_note_frame.dart';
void main() {
const fallback = 220.0;
test('a reported frame is used as is', () {
expect(
videoNoteFrameSize(const Size(480, 480), fallback),
const Size(480, 480),
);
expect(
videoNoteFrameSize(const Size(640, 360), fallback),
const Size(640, 360),
);
});
test('an unreported frame falls back to a square of the circle size', () {
expect(videoNoteFrameSize(Size.zero, fallback), const Size(220, 220));
});
test('a half-reported frame keeps the dimension it does have', () {
expect(
videoNoteFrameSize(const Size(480, 0), fallback),
const Size(480, 220),
);
expect(
videoNoteFrameSize(const Size(0, 480), fallback),
const Size(220, 480),
);
});
test('negative and non-finite dimensions fall back', () {
expect(
videoNoteFrameSize(const Size(-1, -1), fallback),
const Size(220, 220),
);
expect(
videoNoteFrameSize(const Size(double.nan, double.infinity), fallback),
const Size(220, 220),
);
});
}