From e97fe621d6868faf80814cca0bfe4587436b1b0b Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Mon, 4 Apr 2022 14:35:23 +0200 Subject: [PATCH 1/2] chore: Allow custom image resizer to be an async method --- lib/src/client.dart | 4 ++-- lib/src/utils/matrix_file.dart | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index fe0828ee..3977e642 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -104,8 +104,8 @@ class Client extends MatrixApi { final Duration sendTimelineEventTimeout; - MatrixImageFileResizedResponse? Function(MatrixImageFileResizeArguments)? - customImageResizer; + Future Function( + MatrixImageFileResizeArguments)? customImageResizer; /// Create a client /// [clientName] = unique identifier of this client diff --git a/lib/src/utils/matrix_file.dart b/lib/src/utils/matrix_file.dart index 219a9dd9..09f4af27 100644 --- a/lib/src/utils/matrix_file.dart +++ b/lib/src/utils/matrix_file.dart @@ -105,7 +105,8 @@ class MatrixImageFile extends MatrixFile { required String name, int maxDimension = 1600, String? mimeType, - MatrixImageFileResizedResponse? Function(MatrixImageFileResizeArguments)? + Future Function( + MatrixImageFileResizeArguments)? customImageResizer, Future Function(FutureOr Function(U arg) function, U arg)? compute}) async { @@ -115,10 +116,11 @@ class MatrixImageFile extends MatrixFile { fileName: name, calcBlurhash: true, ); - customImageResizer ??= _resize; - final resizedData = compute != null - ? await compute(_resize, arguments) - : _resize(arguments); + final resizedData = customImageResizer != null + ? await customImageResizer(arguments) + : compute != null + ? await compute(_resize, arguments) + : _resize(arguments); if (resizedData == null) { return MatrixImageFile(bytes: bytes, name: name, mimeType: mimeType); @@ -157,7 +159,8 @@ class MatrixImageFile extends MatrixFile { /// computes a thumbnail for the image Future generateThumbnail( {int dimension = Client.defaultThumbnailSize, - MatrixImageFileResizedResponse? Function(MatrixImageFileResizeArguments)? + Future Function( + MatrixImageFileResizeArguments)? customImageResizer, Future Function(FutureOr Function(U arg) function, U arg)? compute}) async { From 53de8195978d62bb02788aaaf1592b1b2c2e0866 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Mon, 4 Apr 2022 14:41:36 +0200 Subject: [PATCH 2/2] chore: Bump version --- CHANGELOG.md | 3 +++ pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aff524a0..6ce068c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [0.8.17] - 4th Apr 2022 +- chore: Allow custom image resizer to be an async method + ## [0.8.16] - 3th Apr 2022 - fix: Missing type check in power level calculation - fix: Post load all users on room opening diff --git a/pubspec.yaml b/pubspec.yaml index 6a627003..c210b7a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: matrix description: Matrix Dart SDK -version: 0.8.16 +version: 0.8.17 homepage: https://famedly.com repository: https://gitlab.com/famedly/company/frontend/famedlysdk.git