оптимизация: слегоньца набурмалдил

This commit is contained in:
Jganenok
2026-06-03 13:55:14 +07:00
parent 3341888ad5
commit 570a4396eb
9 changed files with 229 additions and 123 deletions
+8 -4
View File
@@ -512,12 +512,15 @@ class ChatsModule {
if (accountId == null) return;
final dialogRows = await AppDatabase.loadDialogChats(accountId);
final byParticipant = <int, List<Map<String, dynamic>>>{};
final byParticipant =
<int, List<({Map<String, dynamic> row, CachedChat cached})>>{};
for (final row in dialogRows) {
final cached = CachedChat.fromDbRow(row);
for (final pid in cached.participants.keys) {
if (pid == accountId) continue;
byParticipant.putIfAbsent(pid, () => []).add(row);
byParticipant
.putIfAbsent(pid, () => [])
.add((row: row, cached: cached));
}
}
@@ -529,8 +532,9 @@ class ChatsModule {
final options = ContactCache.getOptions(contactId) ?? const <String>{};
final affected = byParticipant[contactId];
if (affected == null) continue;
for (final row in affected) {
final cached = CachedChat.fromDbRow(row);
for (final entry in affected) {
final row = entry.row;
final cached = entry.cached;
final sameTitle = cached.title == name;
final sameAvatar = (cached.iconUrl ?? '') == (avatar ?? '');
final sameOptions = cached.options.length == options.length &&
+6 -3
View File
@@ -44,10 +44,13 @@ class FoldersModule {
List<dynamic>? foldersOrder,
) {
if (foldersOrder == null || foldersOrder.isEmpty) return;
final orderedIds = foldersOrder.map((id) => id.toString()).toList();
final orderIndex = <String, int>{};
for (var i = 0; i < foldersOrder.length; i++) {
orderIndex.putIfAbsent(foldersOrder[i].toString(), () => i);
}
folders.sort((a, b) {
final aIndex = orderedIds.indexOf(a.id);
final bIndex = orderedIds.indexOf(b.id);
final aIndex = orderIndex[a.id] ?? -1;
final bIndex = orderIndex[b.id] ?? -1;
if (aIndex == -1 && bIndex == -1) return 0;
if (aIndex == -1) return 1;
if (bIndex == -1) return -1;