TF-2311 Remove session page view

(cherry picked from commit 557d67b816c91076d8cafc9aa680e62d5b012f5b)
This commit is contained in:
dab246
2023-11-14 17:29:22 +07:00
committed by Dat Vu
parent 00bfadbfe7
commit 4ff601b4fc
42 changed files with 220 additions and 470 deletions
@@ -0,0 +1,40 @@
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:tmail_ui_user/features/caching/clients/session_hive_cache_client.dart';
import 'package:tmail_ui_user/features/home/data/datasource/session_datasource.dart';
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
import 'package:tmail_ui_user/features/home/data/extensions/session_hive_obj_extension.dart';
import 'package:tmail_ui_user/features/home/data/model/session_hive_obj.dart';
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class HiveSessionDataSourceImpl extends SessionDataSource {
final SessionHiveCacheClient _sessionHiveCacheClient;
final ExceptionThrower _exceptionThrower;
HiveSessionDataSourceImpl(this._sessionHiveCacheClient, this._exceptionThrower);
@override
Future<Session> getSession() {
throw UnimplementedError();
}
@override
Future<void> storeSession(Session session) {
return Future.sync(() async {
return _sessionHiveCacheClient.insertItem(SessionHiveObj.keyValue, session.toHiveObj());
}).catchError(_exceptionThrower.throwException);
}
@override
Future<Session> getStoredSession() {
return Future.sync(() async {
final sessionHiveObj = await _sessionHiveCacheClient.getItem(SessionHiveObj.keyValue);
if (sessionHiveObj != null) {
return sessionHiveObj.toSession();
} else {
throw NotFoundSessionException();
}
}).catchError(_exceptionThrower.throwException);
}
}
@@ -0,0 +1,29 @@
import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:tmail_ui_user/features/home/data/datasource/session_datasource.dart';
import 'package:tmail_ui_user/features/home/data/network/session_api.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class SessionDataSourceImpl extends SessionDataSource {
final SessionAPI _sessionAPI;
final ExceptionThrower _exceptionThrower;
SessionDataSourceImpl(this._sessionAPI, this._exceptionThrower);
@override
Future<Session> getSession() {
return Future.sync(() async {
return await _sessionAPI.getSession();
}).catchError(_exceptionThrower.throwException);
}
@override
Future<void> storeSession(Session session) {
throw UnimplementedError();
}
@override
Future<Session> getStoredSession() {
throw UnimplementedError();
}
}