chore: Follow up crop circle notification avatars
This commit is contained in:
parent
200f2c34be
commit
e7034184d6
3 changed files with 18 additions and 46 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:image/image.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
extension ClientDownloadContentExtension on Client {
|
||||
|
|
@ -10,6 +11,7 @@ extension ClientDownloadContentExtension on Client {
|
|||
bool isThumbnail = false,
|
||||
bool? animated,
|
||||
ThumbnailMethod? thumbnailMethod,
|
||||
bool rounded = false,
|
||||
}) async {
|
||||
// To stay compatible with previous storeKeys:
|
||||
final cacheKey = isThumbnail
|
||||
|
|
@ -44,10 +46,17 @@ extension ClientDownloadContentExtension on Client {
|
|||
if (response.statusCode != 200) {
|
||||
throw Exception();
|
||||
}
|
||||
final remoteData = response.bodyBytes;
|
||||
var imageData = response.bodyBytes;
|
||||
|
||||
await database?.storeFile(cacheKey, remoteData, 0);
|
||||
if (rounded) {
|
||||
final image = decodeImage(imageData);
|
||||
if (image != null) {
|
||||
imageData = copyCropCircle(image).toUint8List();
|
||||
}
|
||||
}
|
||||
|
||||
return remoteData;
|
||||
await database?.storeFile(cacheKey, imageData, 0);
|
||||
|
||||
return imageData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue