Fix local image file issue on windows

This commit is contained in:
HankG 2022-04-06 17:26:47 -04:00
parent c72e76eb26
commit e4f669d9eb

View file

@ -44,7 +44,7 @@ class MediaWrapperComponent extends StatelessWidget {
if (mediaAttachment.explicitType == AttachmentMediaType.video) {
final title = "Video (click to play): " + mediaAttachment.title;
final thumbnailImageResult = _uriToImage(
mediaAttachment.thumbnailUri, archiveService.pathMappingService,
mediaAttachment.thumbnailUri.toString(), archiveService.pathMappingService,
imageTypeName: 'thumbnail image');
if (thumbnailImageResult.image != null) {
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'}) {
if (uri.toString().startsWith('https://interncache')) {
if (uri.startsWith('https://interncache')) {
return _ImageAndPathResult.none();
}
if (uri.scheme.startsWith('http')) {
if (uri.startsWith('http')) {
final networkUrl = uri.toString();
try {
return _ImageAndPathResult(Image.network(networkUrl), networkUrl);
@ -127,7 +127,7 @@ class MediaWrapperComponent extends StatelessWidget {
return _ImageAndPathResult.none();
}
if (uri.path.endsWith('mp4')) {
if (uri.endsWith('mp4')) {
return _ImageAndPathResult.none();
}
@ -171,13 +171,13 @@ class MediaWrapperComponent extends StatelessWidget {
return InkWell(onTap: onTap, child: imageWidget);
}
Uri _calculatePath(ArchiveServiceProvider archiveService) {
String _calculatePath(ArchiveServiceProvider archiveService) {
final url = mediaAttachment.uri.toString();
String basePath = '';
if (url.startsWith('http')) {
final localCacheFile = archiveService.getImageByUrl(url);
if (localCacheFile.isFailure) {
return mediaAttachment.uri;
return mediaAttachment.uri.toString();
}
basePath = localCacheFile.value.localFilename;
@ -185,7 +185,7 @@ class MediaWrapperComponent extends StatelessWidget {
basePath = mediaAttachment.uri.path;
}
return Uri.parse(basePath);
return basePath;
}
}