TF-3416 Persist preview EML content when make reload page action

This commit is contained in:
dab246
2025-01-13 12:50:35 +07:00
committed by Dat H. Pham
parent d304083b2e
commit 0ce99c745c
28 changed files with 623 additions and 40 deletions
@@ -0,0 +1,27 @@
import 'package:collection/collection.dart';
import 'package:tmail_ui_user/features/caching/exceptions/local_storage_exception.dart';
import 'package:universal_html/html.dart' as html;
class SessionStorageManager {
void save(String key, String value) {
html.window.sessionStorage.addAll({key: value});
}
String get(String key) {
final entry = html.window.sessionStorage
.entries
.firstWhereOrNull((entry) => entry.key == key);
if (entry != null) {
return entry.value;
} else {
throw NotFoundDataWithThisKeyException();
}
}
void remove(String key) {
html.window.sessionStorage.remove(key);
}
}