diff --git a/fediverse_archive_browser/lib/src/components/media_wrapper_component.dart b/fediverse_archive_browser/lib/src/components/media_wrapper_component.dart index 5fc5f8f..ec05edd 100644 --- a/fediverse_archive_browser/lib/src/components/media_wrapper_component.dart +++ b/fediverse_archive_browser/lib/src/components/media_wrapper_component.dart @@ -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; } }