Remove async function for SessionStorageManager

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2025-07-16 10:42:49 +07:00
committed by Dat H. Pham
parent ee39f16102
commit 6f87058459
3 changed files with 12 additions and 12 deletions
@@ -7,11 +7,11 @@ class SessionStorageManager {
final html.Storage sessionStorage = html.window.sessionStorage; final html.Storage sessionStorage = html.window.sessionStorage;
Future<void> save(String key, String value) async { void save(String key, String value) {
return sessionStorage.addAll({key: value}); sessionStorage.addAll({key: value});
} }
Future<String> get(String key) async { String get(String key) {
final entry = sessionStorage final entry = sessionStorage
.entries .entries
.firstWhereOrNull((entry) => entry.key == key); .firstWhereOrNull((entry) => entry.key == key);
@@ -23,7 +23,7 @@ class SessionStorageManager {
} }
} }
Future<void> remove(String key) async { void remove(String key) {
if (sessionStorage.containsKey(key)) { if (sessionStorage.containsKey(key)) {
sessionStorage.remove(key); sessionStorage.remove(key);
} }
@@ -217,8 +217,8 @@ class EmailSessionStorageDatasourceImpl extends EmailDataSource {
@override @override
Future<void> storePreviewEMLContentToSessionStorage(EMLPreviewer emlPreviewer) { Future<void> storePreviewEMLContentToSessionStorage(EMLPreviewer emlPreviewer) {
return Future.sync(() async { return Future.sync(() {
return await _sessionStorageManager.save( return _sessionStorageManager.save(
emlPreviewer.id, emlPreviewer.id,
jsonEncode(emlPreviewer.toJson()), jsonEncode(emlPreviewer.toJson()),
); );
@@ -232,8 +232,8 @@ class EmailSessionStorageDatasourceImpl extends EmailDataSource {
@override @override
Future<EMLPreviewer> getPreviewEMLContentInMemory(String keyStored) { Future<EMLPreviewer> getPreviewEMLContentInMemory(String keyStored) {
return Future.sync(() async { return Future.sync(() {
final data = await _sessionStorageManager.get(keyStored); final data = _sessionStorageManager.get(keyStored);
return EMLPreviewer.fromJson(jsonDecode(data)); return EMLPreviewer.fromJson(jsonDecode(data));
}).catchError(_exceptionThrower.throwException); }).catchError(_exceptionThrower.throwException);
} }
@@ -140,8 +140,8 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
@override @override
Future<String> getAuthenticationInfo() { Future<String> getAuthenticationInfo() {
return Future.sync(() async { return Future.sync(() {
return await _sessionStorageManager.get( return _sessionStorageManager.get(
OIDCConstant.authResponseKey, OIDCConstant.authResponseKey,
); );
}).catchError(_cacheExceptionThrower.throwException); }).catchError(_cacheExceptionThrower.throwException);
@@ -156,8 +156,8 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
@override @override
Future<void> removeAuthDestinationUrl() { Future<void> removeAuthDestinationUrl() {
return Future.sync(() async { return Future.sync(() {
return await _sessionStorageManager.remove( return _sessionStorageManager.remove(
LoginConstants.AUTH_DESTINATION_KEY, LoginConstants.AUTH_DESTINATION_KEY,
); );
}).catchError(_cacheExceptionThrower.throwException); }).catchError(_cacheExceptionThrower.throwException);