feat: Persist label state after get all labels
This commit is contained in:
@@ -6,7 +6,7 @@ import 'package:tmail_ui_user/features/labels/domain/model/edit_label_request.da
|
||||
import 'package:tmail_ui_user/features/labels/data/model/label_change_response.dart';
|
||||
|
||||
abstract class LabelDatasource {
|
||||
Future<List<Label>> getAllLabels(AccountId accountId);
|
||||
Future<({List<Label> labels, State? newState})> getAllLabels(AccountId accountId);
|
||||
|
||||
Future<Label> createNewLabel(AccountId accountId, Label labelData);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class LabelDatasourceImpl extends LabelDatasource {
|
||||
LabelDatasourceImpl(this._labelApi, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<List<Label>> getAllLabels(AccountId accountId) {
|
||||
Future<({List<Label> labels, State? newState})> getAllLabels(AccountId accountId) {
|
||||
return Future.sync(() async {
|
||||
return await _labelApi.getAllLabels(accountId);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
|
||||
@@ -24,7 +24,7 @@ class LabelApi
|
||||
|
||||
LabelApi(this._httpClient, this._uuid);
|
||||
|
||||
Future<List<Label>> getAllLabels(AccountId accountId) async {
|
||||
Future<({List<Label> labels, State? newState})> getAllLabels(AccountId accountId) async {
|
||||
final builder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final method = GetLabelMethod(accountId);
|
||||
final invocation = builder.invocation(method);
|
||||
@@ -37,7 +37,7 @@ class LabelApi
|
||||
GetLabelResponse.deserialize,
|
||||
);
|
||||
|
||||
return response?.list ?? [];
|
||||
return (labels: response?.list ?? [], newState: response?.state);
|
||||
}
|
||||
|
||||
Future<Label> createNewLabel(AccountId accountId, Label labelData) async {
|
||||
|
||||
@@ -14,7 +14,7 @@ class LabelRepositoryImpl extends LabelRepository {
|
||||
LabelRepositoryImpl(this._labelDatasource);
|
||||
|
||||
@override
|
||||
Future<List<Label>> getAllLabels(AccountId accountId) {
|
||||
Future<({List<Label> labels, State? newState})> getAllLabels(AccountId accountId) {
|
||||
return _labelDatasource.getAllLabels(accountId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user