Hot fix after some reload minimized composer should be lost body
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:http_parser/http_parser.dart';
|
||||
import 'package:jmap_dart_client/http/converter/id_nullable_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/media_type_nullable_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/part_id_nullable_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/unsigned_int_nullable_converter.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/email/email_body_part.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:uri/uri.dart';
|
||||
|
||||
part 'attachment.g.dart';
|
||||
|
||||
@JsonSerializable(
|
||||
includeIfNull: false,
|
||||
explicitToJson: true,
|
||||
converters: [
|
||||
PartIdNullableConverter(),
|
||||
IdNullableConverter(),
|
||||
UnsignedIntNullableConverter(),
|
||||
MediaTypeNullableConverter(),
|
||||
],
|
||||
)
|
||||
class Attachment with EquatableMixin {
|
||||
|
||||
static const String eventICSSubtype = 'ics';
|
||||
@@ -62,6 +79,10 @@ class Attachment with EquatableMixin {
|
||||
}
|
||||
}
|
||||
|
||||
factory Attachment.fromJson(Map<String, dynamic> json) => _$AttachmentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$AttachmentToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
partId,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'package:core/utils/string_convert.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:model/email/email_content_type.dart';
|
||||
|
||||
class EmailContent with EquatableMixin {
|
||||
|
||||
static const defaultHtmlTagsWrapContent = '<html><head></head><body></body></html>';
|
||||
|
||||
final String content;
|
||||
final EmailContentType type;
|
||||
|
||||
@@ -23,28 +21,6 @@ extension EmailContentExtension on EmailContent {
|
||||
.replaceAll('\n', '<br/>')
|
||||
.replaceAll('\n\n', '<br/>');
|
||||
}
|
||||
final newContent = _getContentOriginal(content);
|
||||
return newContent;
|
||||
}
|
||||
|
||||
String _getContentOriginal(String content) {
|
||||
if (content == EmailContent.defaultHtmlTagsWrapContent ||
|
||||
content.trim().isEmpty) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const firstTags = '<html><head></head><body>';
|
||||
const latestTags = '</body></html>';
|
||||
if (content.startsWith(firstTags) && content.endsWith(latestTags)) {
|
||||
const firstIndex = firstTags.length;
|
||||
final latestIndex = content.length - latestTags.length;
|
||||
|
||||
if (latestIndex > firstIndex) {
|
||||
final contentOriginal = content.substring(firstIndex, latestIndex);
|
||||
return contentOriginal;
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
return StringConvert.getContentOriginal(content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user