|
|
@ -354,19 +354,27 @@ class NeonUrlImage extends StatelessWidget { |
|
|
|
Widget build(final BuildContext context) { |
|
|
|
Widget build(final BuildContext context) { |
|
|
|
final account = this.account ?? NeonProvider.of<AccountsBloc>(context).activeAccount.value!; |
|
|
|
final account = this.account ?? NeonProvider.of<AccountsBloc>(context).activeAccount.value!; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final uri = Uri.parse(url); |
|
|
|
|
|
|
|
final dataUri = uri.data; |
|
|
|
|
|
|
|
|
|
|
|
return NeonCachedImage( |
|
|
|
return NeonCachedImage( |
|
|
|
getImage: () async { |
|
|
|
getImage: () async { |
|
|
|
final uri = account.completeUri(Uri.parse(url)); |
|
|
|
if (dataUri != null) { |
|
|
|
|
|
|
|
return dataUri.contentAsBytes(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final completedUri = account.completeUri(uri); |
|
|
|
final headers = <String, String>{}; |
|
|
|
final headers = <String, String>{}; |
|
|
|
|
|
|
|
|
|
|
|
// Only send the authentication headers when sending the request to the server of the account |
|
|
|
// Only send the authentication headers when sending the request to the server of the account |
|
|
|
if (uri.toString().startsWith(account.serverURL.toString()) && account.client.authentications.isNotEmpty) { |
|
|
|
if (completedUri.toString().startsWith(account.serverURL.toString()) && |
|
|
|
|
|
|
|
account.client.authentications.isNotEmpty) { |
|
|
|
headers.addAll(account.client.authentications.first.headers); |
|
|
|
headers.addAll(account.client.authentications.first.headers); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final response = await account.client.executeRawRequest( |
|
|
|
final response = await account.client.executeRawRequest( |
|
|
|
'GET', |
|
|
|
'GET', |
|
|
|
uri, |
|
|
|
completedUri, |
|
|
|
headers, |
|
|
|
headers, |
|
|
|
null, |
|
|
|
null, |
|
|
|
const {200}, |
|
|
|
const {200}, |
|
|
@ -377,7 +385,7 @@ class NeonUrlImage extends StatelessWidget { |
|
|
|
cacheKey: '${account.id}-$url', |
|
|
|
cacheKey: '${account.id}-$url', |
|
|
|
reviver: reviver, |
|
|
|
reviver: reviver, |
|
|
|
writeCache: writeCache, |
|
|
|
writeCache: writeCache, |
|
|
|
isSvgHint: isSvgHint, |
|
|
|
isSvgHint: isSvgHint || (dataUri?.mimeType.contains('svg') ?? false), |
|
|
|
size: size, |
|
|
|
size: size, |
|
|
|
fit: fit, |
|
|
|
fit: fit, |
|
|
|
svgColorFilter: svgColorFilter, |
|
|
|
svgColorFilter: svgColorFilter, |
|
|
|