Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Offline files #222

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Offline files #222

wants to merge 11 commits into from

Conversation

MarcelGarus
Copy link
Contributor

@MarcelGarus MarcelGarus commented Mar 18, 2020

Closes: #60

Makes files available offline. When clicking on a file, it's downloaded only if necessary. Files that have already been downloaded, have an offline pin next to them:
image
Clicking on a downloaded file opens it. For now, files don't open automatically after they are downloaded and the pin doesn't appear when the download completed but only when revisiting the screen. Both of these limitations stem from the difficulty of detecting the finishing of a download. This can be easily resolved once the flutter_downloader provides an API with Futures instead of callbacks on other isolates, which I'm working on: fluttercommunity/flutter_downloader#256

@MarcelGarus MarcelGarus added T: feat Type: :tada: New Features L: widgets Layer: Includes changes to the widgets layer L: data Layer: Includes changes to the data layer L: BLoC/service Layer: Includes changes to the BLoC/service layer M: file Module: file labels Mar 18, 2020
@MarcelGarus MarcelGarus added this to the MVP MVP milestone Mar 18, 2020
@MarcelGarus MarcelGarus requested a review from JonasWanke March 18, 2020 16:12
@MarcelGarus MarcelGarus self-assigned this Mar 18, 2020
@github-actions
Copy link

github-actions bot commented Mar 18, 2020

Flutter Analyze found 0 issues ✅

Generated by 🚫 Danger

Copy link
Contributor

@JonasWanke JonasWanke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I would prefer to store downloaded files in the app's cache directory so we have full control over it and the user can make space easily. (The following points assume this.) See Make it possible to view files without downloading them to storage #61 (comment)
  • When a file gets deleted on the server, we remove the locally cached copy, e.g. when we next fetch the containing directory.
  • We should provide the user with a possibility to delete the local copy.
  • Even though we have a local copy, it might not be up to date → store updatedAt for each cached fille?

Comment on lines 74 to 83
String get extension {
final lastDot = name.lastIndexOf('.');
return lastDot == null ? null : name.substring(lastDot + 1);
}

Future<io.File> get localFile async {
final directory = await getExternalStorageDirectory();
final fileName = extension == null ? id.toString() : '$id.$extension';
return io.File('${directory.path}/$fileName');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to simplify this code with path

lib/file/widgets/file_thumbnail.dart Show resolved Hide resolved
@JonasWanke JonasWanke removed this from the MVP MVP milestone Mar 28, 2020
@JonasWanke JonasWanke changed the base branch from master to main January 14, 2021 09:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
L: BLoC/service Layer: Includes changes to the BLoC/service layer L: data Layer: Includes changes to the data layer L: widgets Layer: Includes changes to the widgets layer M: file Module: file T: feat Type: :tada: New Features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make files available offline
2 participants