Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incorrect expiration date for files in mySpace #943

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 48 additions & 42 deletions data/lib/src/network/model/response/document_details_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,66 +36,68 @@ import 'package:data/src/network/model/share/document_details_received_share_dto
import 'package:domain/domain.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:http_parser/http_parser.dart';
import 'package:data/src/network/model/converter/datetime_nullable_converter.dart';

import 'document_response.dart';

part 'document_details_response.g.dart';

@JsonSerializable()
@DatetimeConverter()
@DatetimeNullableConverter()
class DocumentDetailsResponse extends DocumentResponse {
DocumentDetailsResponse(
DocumentId documentId,
String description,
DateTime creationDate,
DateTime modificationDate,
DateTime expirationDate,
bool ciphered,
String name,
int size,
String sha256sum,
bool hasThumbnail,
int shared,
MediaType mediaType,
this.shares
) : super(
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
mediaType
);
DocumentId documentId,
String description,
DateTime creationDate,
DateTime modificationDate,
DateTime? expirationDate,
bool ciphered,
String name,
int size,
String sha256sum,
bool hasThumbnail,
int shared,
MediaType mediaType,
this.shares)
: super(
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
mediaType);

final List<DocumentDetailsReceivedShareDto> shares;

@override
factory DocumentDetailsResponse.fromJson(Map<String, dynamic> json) => _$DocumentDetailsResponseFromJson(json);
factory DocumentDetailsResponse.fromJson(Map<String, dynamic> json) =>
_$DocumentDetailsResponseFromJson(json);

@override
Map<String, dynamic> toJson() => _$DocumentDetailsResponseToJson(this);

@override
List<Object> get props => [
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
shares
];
documentId,
description,
creationDate,
modificationDate,
expirationDate!,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
shares
];
}

extension DocumentDetailsResponseExtension on DocumentDetailsResponse {
Expand All @@ -113,6 +115,10 @@ extension DocumentDetailsResponseExtension on DocumentDetailsResponse {
hasThumbnail,
shared,
mediaType,
shares.isNotEmpty ? shares.map((share) => share.toDocumentDetailsReceivedShare()).toList() : []);
shares.isNotEmpty
? shares
.map((share) => share.toDocumentDetailsReceivedShare())
.toList()
: []);
}
}
19 changes: 14 additions & 5 deletions data/lib/src/network/model/response/document_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ import 'package:domain/domain.dart';
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:http_parser/http_parser.dart';
import 'package:data/src/network/model/converter/datetime_nullable_converter.dart';

part 'document_response.g.dart';

@JsonSerializable()
@DatetimeConverter()
@DatetimeNullableConverter()
class DocumentResponse extends Equatable {
DocumentResponse(
this.documentId,
Expand All @@ -57,24 +59,31 @@ class DocumentResponse extends Equatable {
this.shared,
this.mediaType);

@JsonKey(name: Attribute.uuid, fromJson: documentIdFromJson, toJson: documentIdToJson)
@JsonKey(
name: Attribute.uuid,
fromJson: documentIdFromJson,
toJson: documentIdToJson)
final DocumentId documentId;

final String description;
final DateTime creationDate;
final DateTime modificationDate;
final DateTime expirationDate;
final DateTime? expirationDate;
final bool ciphered;
final String name;
final int size;
final String sha256sum;
final bool hasThumbnail;
final int shared;

@JsonKey(name: Attribute.type, fromJson: mediaTypeFromJson, toJson: mediaTypeToJson)
@JsonKey(
name: Attribute.type,
fromJson: mediaTypeFromJson,
toJson: mediaTypeToJson)
final MediaType mediaType;

factory DocumentResponse.fromJson(Map<String, dynamic> json) => _$DocumentResponseFromJson(json);
factory DocumentResponse.fromJson(Map<String, dynamic> json) =>
_$DocumentResponseFromJson(json);

Map<String, dynamic> toJson() => _$DocumentResponseToJson(this);

Expand All @@ -84,7 +93,7 @@ class DocumentResponse extends Equatable {
description,
creationDate,
modificationDate,
expirationDate,
expirationDate!,
ciphered,
name,
size,
Expand Down
39 changes: 18 additions & 21 deletions domain/lib/src/model/document/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -64,30 +64,27 @@ class Document extends Equatable {
this.hasThumbnail,
this.shared,
this.mediaType,
{
this.localPath,
this.syncOfflineState
}
);
{this.localPath,
this.syncOfflineState});

bool isShared() => shared != 0;

bool isOfflineMode() => localPath != null ? localPath!.isNotEmpty : false;

@override
List<Object?> get props => [
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
mediaType,
localPath,
syncOfflineState
];
}
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
mediaType,
localPath,
syncOfflineState
];
}
57 changes: 28 additions & 29 deletions domain/lib/src/model/document/document_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,34 @@ class DocumentDetails extends Document {
hasThumbnail,
shared,
mediaType,
this.shares
) : super(
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
mediaType
);
this.shares)
: super(
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
mediaType);

@override
List<Object> get props => [
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
shares
];
List<Object?> get props => [
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared,
shares
];
}
34 changes: 15 additions & 19 deletions lib/presentation/model/file/document_presentation_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -102,28 +102,24 @@ class DocumentPresentationFile extends Equatable implements PresentationFile {

@override
Widget fileIcon() {
return SvgPicture.asset(
mediaType.getFileTypeImagePath(imagePath),
width: 16,
height: 20,
fit: BoxFit.fill
);
return SvgPicture.asset(mediaType.getFileTypeImagePath(imagePath),
width: 16, height: 20, fit: BoxFit.fill);
}

bool isShared() => shared != 0;

@override
List<Object> get props => [
documentId,
description,
creationDate,
modificationDate,
expirationDate,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared
];
documentId,
description,
creationDate,
modificationDate,
expirationDate!,
ciphered,
name,
size,
sha256sum,
hasThumbnail,
shared
];
}
Loading
Loading