mirror of
https://gitlab.com/mysocialportal/fediverse-archiving-tools.git
synced 2024-10-18 08:53:31 +00:00
Fix local image file issue on windows
This commit is contained in:
parent
c72e76eb26
commit
e4f669d9eb
1 changed files with 8 additions and 8 deletions
|
@ -44,7 +44,7 @@ class MediaWrapperComponent extends StatelessWidget {
|
||||||
if (mediaAttachment.explicitType == AttachmentMediaType.video) {
|
if (mediaAttachment.explicitType == AttachmentMediaType.video) {
|
||||||
final title = "Video (click to play): " + mediaAttachment.title;
|
final title = "Video (click to play): " + mediaAttachment.title;
|
||||||
final thumbnailImageResult = _uriToImage(
|
final thumbnailImageResult = _uriToImage(
|
||||||
mediaAttachment.thumbnailUri, archiveService.pathMappingService,
|
mediaAttachment.thumbnailUri.toString(), archiveService.pathMappingService,
|
||||||
imageTypeName: 'thumbnail image');
|
imageTypeName: 'thumbnail image');
|
||||||
if (thumbnailImageResult.image != null) {
|
if (thumbnailImageResult.image != null) {
|
||||||
return _createFinalWidget(
|
return _createFinalWidget(
|
||||||
|
@ -110,13 +110,13 @@ class MediaWrapperComponent extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ImageAndPathResult _uriToImage(Uri uri, PathMappingService mapper,
|
_ImageAndPathResult _uriToImage(String uri, PathMappingService mapper,
|
||||||
{String imageTypeName = 'image'}) {
|
{String imageTypeName = 'image'}) {
|
||||||
if (uri.toString().startsWith('https://interncache')) {
|
if (uri.startsWith('https://interncache')) {
|
||||||
return _ImageAndPathResult.none();
|
return _ImageAndPathResult.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri.scheme.startsWith('http')) {
|
if (uri.startsWith('http')) {
|
||||||
final networkUrl = uri.toString();
|
final networkUrl = uri.toString();
|
||||||
try {
|
try {
|
||||||
return _ImageAndPathResult(Image.network(networkUrl), networkUrl);
|
return _ImageAndPathResult(Image.network(networkUrl), networkUrl);
|
||||||
|
@ -127,7 +127,7 @@ class MediaWrapperComponent extends StatelessWidget {
|
||||||
return _ImageAndPathResult.none();
|
return _ImageAndPathResult.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri.path.endsWith('mp4')) {
|
if (uri.endsWith('mp4')) {
|
||||||
return _ImageAndPathResult.none();
|
return _ImageAndPathResult.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,13 +171,13 @@ class MediaWrapperComponent extends StatelessWidget {
|
||||||
return InkWell(onTap: onTap, child: imageWidget);
|
return InkWell(onTap: onTap, child: imageWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uri _calculatePath(ArchiveServiceProvider archiveService) {
|
String _calculatePath(ArchiveServiceProvider archiveService) {
|
||||||
final url = mediaAttachment.uri.toString();
|
final url = mediaAttachment.uri.toString();
|
||||||
String basePath = '';
|
String basePath = '';
|
||||||
if (url.startsWith('http')) {
|
if (url.startsWith('http')) {
|
||||||
final localCacheFile = archiveService.getImageByUrl(url);
|
final localCacheFile = archiveService.getImageByUrl(url);
|
||||||
if (localCacheFile.isFailure) {
|
if (localCacheFile.isFailure) {
|
||||||
return mediaAttachment.uri;
|
return mediaAttachment.uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
basePath = localCacheFile.value.localFilename;
|
basePath = localCacheFile.value.localFilename;
|
||||||
|
@ -185,7 +185,7 @@ class MediaWrapperComponent extends StatelessWidget {
|
||||||
basePath = mediaAttachment.uri.path;
|
basePath = mediaAttachment.uri.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Uri.parse(basePath);
|
return basePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue