This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Offline files #222
Open
MarcelGarus
wants to merge
11
commits into
main
Choose a base branch
from
offline-files
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Offline files #222
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Flutter Analyze found 0 issues ✅Generated by 🚫 Danger |
JonasWanke
suggested changes
Mar 18, 2020
There was a problem hiding this 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?
lib/file/data.dart
Outdated
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'); | ||
} |
There was a problem hiding this comment.
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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 withFuture
s instead of callbacks on other isolates, which I'm working on: fluttercommunity/flutter_downloader#256