Skip to content

Commit

Permalink
neon_files: Do not assume props are returned when requested
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin committed Jun 10, 2023
1 parent 734369a commit 0c5cb15
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/neon/neon_files/lib/models/file_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class FileDetails {

final bool isDirectory;

final int size;
final int? size;

final String? etag;

final String? mimeType;

final DateTime lastModified;
final DateTime? lastModified;

final bool? hasPreview;

Expand Down
5 changes: 4 additions & 1 deletion packages/neon/neon_files/lib/pages/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class FilesDetailsPage extends StatelessWidget {
details.isDirectory
? AppLocalizations.of(context).detailsFolderSize
: AppLocalizations.of(context).detailsFileSize: filesize(details.size, 1),
AppLocalizations.of(context).detailsLastModified: details.lastModified.toLocal().toIso8601String(),
if (details.lastModified != null) ...{
AppLocalizations.of(context).detailsLastModified:
details.lastModified!.toLocal().toIso8601String(),
},
if (details.isFavorite != null) ...{
AppLocalizations.of(context).detailsIsFavorite: details.isFavorite!
? AppLocalizations.of(context).actionYes
Expand Down
2 changes: 1 addition & 1 deletion packages/neon/neon_files/lib/pages/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class _FilesMainPageState extends State<FilesMainPage> {
filesBloc: bloc,
onPickFile: (final details) async {
final sizeWarning = bloc.options.downloadSizeWarning.value;
if (sizeWarning != null && details.size > sizeWarning) {
if (sizeWarning != null && details.size != null && details.size! > sizeWarning) {
// ignore: use_build_context_synchronously
if (!(await showConfirmationDialog(
context,
Expand Down
16 changes: 9 additions & 7 deletions packages/neon/neon_files/lib/widgets/browser_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
isDirectory: matchingUploadTasks.isEmpty && file.isDirectory,
size: matchingUploadTasks.isNotEmpty
? matchingUploadTasks.first.size
: file.size!,
: file.size,
etag: matchingUploadTasks.isNotEmpty ? null : file.etag,
mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType,
lastModified: matchingUploadTasks.isNotEmpty
? matchingUploadTasks.first.lastModified
: file.lastModified!,
: file.lastModified,
hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview,
isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite,
),
Expand Down Expand Up @@ -235,10 +235,12 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
),
subtitle: Row(
children: [
RelativeTime(
date: details.lastModified,
),
if (details.size > 0) ...[
if (details.lastModified != null) ...[
RelativeTime(
date: details.lastModified!,
),
],
if (details.size != null && details.size! > 0) ...[
const SizedBox(
width: 10,
),
Expand Down Expand Up @@ -396,7 +398,7 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
break;
case FilesFileAction.sync:
final sizeWarning = widget.bloc.options.downloadSizeWarning.value;
if (sizeWarning != null && details.size > sizeWarning) {
if (sizeWarning != null && details.size != null && details.size! > sizeWarning) {
// ignore: use_build_context_synchronously
if (!(await showConfirmationDialog(
context,
Expand Down

0 comments on commit 0c5cb15

Please sign in to comment.