TF-973 Fix can not create folder with name contain special
This commit is contained in:
@@ -123,7 +123,7 @@ class AppToast {
|
|||||||
fToast.showToast(
|
fToast.showToast(
|
||||||
child: toast,
|
child: toast,
|
||||||
gravity: ToastGravity.BOTTOM,
|
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/account_id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.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/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/patch_object.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/request/reference_path.dart';
|
import 'package:jmap_dart_client/jmap/core/request/reference_path.dart';
|
||||||
@@ -125,16 +127,34 @@ class MailboxAPI {
|
|||||||
setMailboxInvocation.methodCallId,
|
setMailboxInvocation.methodCallId,
|
||||||
SetMailboxResponse.deserialize);
|
SetMailboxResponse.deserialize);
|
||||||
|
|
||||||
return Future.sync(() async {
|
final mapMailboxCreated = setMailboxResponse?.created;
|
||||||
final newMailbox = setMailboxResponse?.created?[request.creationId];
|
if (mapMailboxCreated != null &&
|
||||||
if (newMailbox != null) {
|
mapMailboxCreated.containsKey(request.creationId)) {
|
||||||
return newMailbox.addMailboxName(newMailbox, request.newName, parentId: request.parentId);
|
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 {
|
} else {
|
||||||
return null;
|
throw UnknownMethodResponse(description: setError?.description);
|
||||||
}
|
}
|
||||||
}).catchError((error) {
|
} else {
|
||||||
throw error;
|
throw UnknownMethodResponse();
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> deleteMultipleMailbox(Session session, AccountId accountId, List<MailboxId> mailboxIds) async {
|
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:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.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/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
@@ -411,11 +412,17 @@ class MailboxController extends BaseMailboxController {
|
|||||||
|
|
||||||
void _createNewMailboxFailure(CreateNewMailboxFailure failure) {
|
void _createNewMailboxFailure(CreateNewMailboxFailure failure) {
|
||||||
if (currentOverlayContext != null && currentContext != null) {
|
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(
|
_appToast.showToastWithIcon(
|
||||||
currentOverlayContext!,
|
currentOverlayContext!,
|
||||||
textColor: AppColor.toastErrorBackgroundColor,
|
message: messageError,
|
||||||
message: AppLocalizations.of(currentContext!).create_new_mailbox_failure,
|
iconColor: AppColor.toastErrorBackgroundColor,
|
||||||
icon: _imagePaths.icFolderMailbox);
|
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(
|
return Mailbox(
|
||||||
id: id,
|
id: id,
|
||||||
name: mailboxName,
|
name: mailboxName,
|
||||||
|
|||||||
Reference in New Issue
Block a user