TF-973 Fix can not create folder with name contain special
This commit is contained in:
@@ -123,7 +123,7 @@ class AppToast {
|
||||
fToast.showToast(
|
||||
child: toast,
|
||||
gravity: ToastGravity.BOTTOM,
|
||||
toastDuration: toastLength ?? Duration(seconds: 2),
|
||||
toastDuration: toastLength ?? Duration(seconds: 3),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import 'package:jmap_dart_client/http/http_client.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/capability/core_capability.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/request/reference_path.dart';
|
||||
@@ -125,16 +127,34 @@ class MailboxAPI {
|
||||
setMailboxInvocation.methodCallId,
|
||||
SetMailboxResponse.deserialize);
|
||||
|
||||
return Future.sync(() async {
|
||||
final newMailbox = setMailboxResponse?.created?[request.creationId];
|
||||
if (newMailbox != null) {
|
||||
return newMailbox.addMailboxName(newMailbox, request.newName, parentId: request.parentId);
|
||||
final mapMailboxCreated = setMailboxResponse?.created;
|
||||
if (mapMailboxCreated != null &&
|
||||
mapMailboxCreated.containsKey(request.creationId)) {
|
||||
final mailboxCreated = mapMailboxCreated[request.creationId]!;
|
||||
final newMailboxCreated = mailboxCreated.toMailbox(
|
||||
request.newName,
|
||||
parentId: request.parentId);
|
||||
return newMailboxCreated;
|
||||
} else {
|
||||
throw _parseErrorForSetMailboxResponse(setMailboxResponse, request.creationId);
|
||||
}
|
||||
}
|
||||
|
||||
_parseErrorForSetMailboxResponse(SetMailboxResponse? response, Id requestId) {
|
||||
final mapError = response?.notCreated ?? response?.notUpdated ?? response?.notDestroyed;
|
||||
if (mapError != null && mapError.containsKey(requestId)) {
|
||||
final setError = mapError[requestId];
|
||||
log('MailboxAPI::_parseErrorForSetMailboxResponse():setError: $setError');
|
||||
if (setError?.type == ErrorMethodResponse.invalidArguments) {
|
||||
throw InvalidArgumentsMethodResponse(description: setError?.description);
|
||||
} else if (setError?.type == ErrorMethodResponse.invalidResultReference) {
|
||||
throw InvalidResultReferenceMethodResponse(description: setError?.description);
|
||||
} else {
|
||||
return null;
|
||||
throw UnknownMethodResponse(description: setError?.description);
|
||||
}
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
});
|
||||
} else {
|
||||
throw UnknownMethodResponse();
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> deleteMultipleMailbox(Session session, AccountId accountId, List<MailboxId> mailboxIds) async {
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
@@ -411,11 +412,17 @@ class MailboxController extends BaseMailboxController {
|
||||
|
||||
void _createNewMailboxFailure(CreateNewMailboxFailure failure) {
|
||||
if (currentOverlayContext != null && currentContext != null) {
|
||||
final exception = failure.exception;
|
||||
var messageError = AppLocalizations.of(currentContext!).create_new_mailbox_failure;
|
||||
if (exception is ErrorMethodResponse) {
|
||||
messageError = exception.description ?? AppLocalizations.of(currentContext!).create_new_mailbox_failure;
|
||||
}
|
||||
|
||||
_appToast.showToastWithIcon(
|
||||
currentOverlayContext!,
|
||||
textColor: AppColor.toastErrorBackgroundColor,
|
||||
message: AppLocalizations.of(currentContext!).create_new_mailbox_failure,
|
||||
icon: _imagePaths.icFolderMailbox);
|
||||
message: messageError,
|
||||
iconColor: AppColor.toastErrorBackgroundColor,
|
||||
icon: _imagePaths.icNotConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ extension MailboxExtension on Mailbox {
|
||||
);
|
||||
}
|
||||
|
||||
Mailbox addMailboxName(Mailbox newMailbox, MailboxName mailboxName, {MailboxId? parentId}) {
|
||||
Mailbox toMailbox(MailboxName mailboxName, {MailboxId? parentId}) {
|
||||
return Mailbox(
|
||||
id: id,
|
||||
name: mailboxName,
|
||||
|
||||
Reference in New Issue
Block a user