From a78f621d4e18ab7696929afcdfec39da393a7509 Mon Sep 17 00:00:00 2001 From: Khaled Njim Date: Mon, 26 Feb 2024 22:56:29 +0100 Subject: [PATCH] LA-1220 Fix: Fixed wrong file expiration date in mySpace --- .../network/model/response/document_details_response.dart | 6 ++++-- data/lib/src/network/model/response/document_response.dart | 6 ++++-- domain/lib/src/model/document/document.dart | 2 +- domain/lib/src/model/document/document_details.dart | 2 +- .../model/file/document_presentation_file.dart | 4 ++-- lib/presentation/redux/states/functionality_state.dart | 7 ++++--- .../myspace/document_details/document_details_widget.dart | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/data/lib/src/network/model/response/document_details_response.dart b/data/lib/src/network/model/response/document_details_response.dart index da615177e..10409a43b 100644 --- a/data/lib/src/network/model/response/document_details_response.dart +++ b/data/lib/src/network/model/response/document_details_response.dart @@ -32,6 +32,7 @@ import 'package:data/src/network/model/converter/data_from_json_converter.dart'; import 'package:data/src/network/model/converter/datetime_converter.dart'; +import 'package:data/src/network/model/converter/datetime_nullable_converter.dart'; import 'package:data/src/network/model/share/document_details_received_share_dto.dart'; import 'package:domain/domain.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -43,13 +44,14 @@ part 'document_details_response.g.dart'; @JsonSerializable() @DatetimeConverter() +@DatetimeNullableConverter() class DocumentDetailsResponse extends DocumentResponse { DocumentDetailsResponse( DocumentId documentId, String description, DateTime creationDate, DateTime modificationDate, - DateTime expirationDate, + DateTime? expirationDate, bool ciphered, String name, int size, @@ -82,7 +84,7 @@ class DocumentDetailsResponse extends DocumentResponse { Map toJson() => _$DocumentDetailsResponseToJson(this); @override - List get props => [ + List get props => [ documentId, description, creationDate, diff --git a/data/lib/src/network/model/response/document_response.dart b/data/lib/src/network/model/response/document_response.dart index 837ac5d53..d6934aaa1 100644 --- a/data/lib/src/network/model/response/document_response.dart +++ b/data/lib/src/network/model/response/document_response.dart @@ -32,6 +32,7 @@ import 'package:data/src/network/model/converter/data_from_json_converter.dart'; import 'package:data/src/network/model/converter/datetime_converter.dart'; +import 'package:data/src/network/model/converter/datetime_nullable_converter.dart'; import 'package:data/src/util/attribute.dart'; import 'package:domain/domain.dart'; import 'package:equatable/equatable.dart'; @@ -42,6 +43,7 @@ part 'document_response.g.dart'; @JsonSerializable() @DatetimeConverter() +@DatetimeNullableConverter() class DocumentResponse extends Equatable { DocumentResponse( this.documentId, @@ -63,7 +65,7 @@ class DocumentResponse extends Equatable { final String description; final DateTime creationDate; final DateTime modificationDate; - final DateTime expirationDate; + final DateTime? expirationDate; final bool ciphered; final String name; final int size; @@ -79,7 +81,7 @@ class DocumentResponse extends Equatable { Map toJson() => _$DocumentResponseToJson(this); @override - List get props => [ + List get props => [ documentId, description, creationDate, diff --git a/domain/lib/src/model/document/document.dart b/domain/lib/src/model/document/document.dart index 5e2c96234..761771f91 100644 --- a/domain/lib/src/model/document/document.dart +++ b/domain/lib/src/model/document/document.dart @@ -40,7 +40,7 @@ class Document extends Equatable { final String description; final DateTime creationDate; final DateTime modificationDate; - final DateTime expirationDate; + final DateTime? expirationDate; final bool ciphered; final String name; final int size; diff --git a/domain/lib/src/model/document/document_details.dart b/domain/lib/src/model/document/document_details.dart index b30bbdbd2..d30c2c6d3 100644 --- a/domain/lib/src/model/document/document_details.dart +++ b/domain/lib/src/model/document/document_details.dart @@ -65,7 +65,7 @@ class DocumentDetails extends Document { ); @override - List get props => [ + List get props => [ documentId, description, creationDate, diff --git a/lib/presentation/model/file/document_presentation_file.dart b/lib/presentation/model/file/document_presentation_file.dart index 7870ceb26..3d78590da 100644 --- a/lib/presentation/model/file/document_presentation_file.dart +++ b/lib/presentation/model/file/document_presentation_file.dart @@ -51,7 +51,7 @@ class DocumentPresentationFile extends Equatable implements PresentationFile { final String description; final DateTime creationDate; final DateTime modificationDate; - final DateTime expirationDate; + final DateTime? expirationDate; final bool ciphered; final String name; final int size; @@ -113,7 +113,7 @@ class DocumentPresentationFile extends Equatable implements PresentationFile { bool isShared() => shared != 0; @override - List get props => [ + List get props => [ documentId, description, creationDate, diff --git a/lib/presentation/redux/states/functionality_state.dart b/lib/presentation/redux/states/functionality_state.dart index 98e8d6d55..4a11bf22b 100644 --- a/lib/presentation/redux/states/functionality_state.dart +++ b/lib/presentation/redux/states/functionality_state.dart @@ -36,6 +36,7 @@ import 'package:domain/src/state/failure.dart'; import 'package:domain/src/state/success.dart'; import 'package:flutter/foundation.dart'; import 'package:linshare_flutter_app/presentation/redux/states/linshare_state.dart'; +import 'package:collection/collection.dart'; @immutable class FunctionalityState extends LinShareState { @@ -91,9 +92,9 @@ extension FunctionalityStateExtension on FunctionalityState { bool isUploadRequestEnable() => _isFunctionalityEnable(FunctionalityIdentifier.UPLOAD_REQUEST); bool _isFunctionalityEnable(FunctionalityIdentifier functionalityIdentifier) { - final functionality = functionalityList.firstWhere( - (element) => (element != null && element.identifier == functionalityIdentifier), - orElse: () => null); + final functionality = functionalityList.firstWhereOrNull( + (element) => (element != null && element.identifier == functionalityIdentifier)); + if (functionality != null) { return functionality.enable; } diff --git a/lib/presentation/widget/myspace/document_details/document_details_widget.dart b/lib/presentation/widget/myspace/document_details/document_details_widget.dart index 9ec380b7c..fac35753f 100644 --- a/lib/presentation/widget/myspace/document_details/document_details_widget.dart +++ b/lib/presentation/widget/myspace/document_details/document_details_widget.dart @@ -132,7 +132,7 @@ class _DocumentDetailsWidgetState extends State { _documentInformationTile(AppLocalizations.of(context).created, state.document?.creationDate.getMMMddyyyyFormatString() ?? ''), _documentInformationTile(AppLocalizations.of(context).expiration, - state.document?.creationDate.getMMMddyyyyFormatString() ?? ''), + state.document?.expirationDate?.getMMMddyyyyFormatString() ?? AppLocalizations.of(context).no_results_found), ], ), Divider(),