TF-3804 Thread Detail Load selected email in parallel with thread metadata
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||
import 'package:model/email/presentation_email.dart';
|
||||
|
||||
class ThreadDetailPresentationUtils {
|
||||
const ThreadDetailPresentationUtils._();
|
||||
@@ -54,4 +56,38 @@ class ThreadDetailPresentationUtils {
|
||||
emailIds.length,
|
||||
);
|
||||
}
|
||||
|
||||
static List<EmailId> refreshEmailIds({
|
||||
required List<EmailId> original,
|
||||
required List<EmailId> created,
|
||||
required List<EmailId> destroyed,
|
||||
}) {
|
||||
return [
|
||||
...original.whereNot(destroyed.contains),
|
||||
...created,
|
||||
];
|
||||
}
|
||||
|
||||
static List<PresentationEmail> refreshPresentationEmails({
|
||||
required List<PresentationEmail> original,
|
||||
required List<PresentationEmail> created,
|
||||
required List<PresentationEmail> updated,
|
||||
required List<EmailId> destroyed,
|
||||
}) {
|
||||
return [
|
||||
...original
|
||||
.whereNot((email) => destroyed.contains(email.id))
|
||||
.map((email) {
|
||||
final updatedInOriginal = updated.firstWhereOrNull(
|
||||
(updatedEmail) => updatedEmail.id == email.id,
|
||||
);
|
||||
|
||||
return email.copyWith(
|
||||
keywords: updatedInOriginal?.keywords,
|
||||
mailboxIds: updatedInOriginal?.mailboxIds,
|
||||
);
|
||||
}),
|
||||
...created,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user