Skip to content

Commit

Permalink
fix(mobile): Prefer sharing local assets to remote (#7245)
Browse files Browse the repository at this point in the history
Prefer sharing local assets to remote
  • Loading branch information
martyfuhry authored Feb 20, 2024
1 parent b896d45 commit e338e4d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mobile/lib/shared/services/share.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ class ShareService {
final downloadedXFiles = <XFile>[];

for (var asset in assets) {
if (asset.isRemote) {
if (asset.isLocal) {
// Prefer local assets to share
File? f = await asset.local!.file;
downloadedXFiles.add(XFile(f!.path));
} else if (asset.isRemote) {
// Download remote asset otherwise
final tempDir = await getTemporaryDirectory();
final fileName = asset.fileName;
final tempFile = await File('${tempDir.path}/$fileName').create();
Expand All @@ -43,9 +48,6 @@ class ShareService {

tempFile.writeAsBytesSync(res.bodyBytes);
downloadedXFiles.add(XFile(tempFile.path));
} else {
File? f = await asset.local!.file;
downloadedXFiles.add(XFile(f!.path));
}
}

Expand Down

0 comments on commit e338e4d

Please sign in to comment.