From 0fc02086a3d641496eb01943ae0c68a97c0b277d Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Sat, 26 Oct 2024 13:11:36 +1030 Subject: [PATCH] Fix SSO brand images not loading correctly (#374) --- .../matrix/auth/matrix_sso_login_flow.dart | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/commet/lib/client/matrix/auth/matrix_sso_login_flow.dart b/commet/lib/client/matrix/auth/matrix_sso_login_flow.dart index 2e12e855..47bac913 100644 --- a/commet/lib/client/matrix/auth/matrix_sso_login_flow.dart +++ b/commet/lib/client/matrix/auth/matrix_sso_login_flow.dart @@ -1,7 +1,6 @@ import 'package:commet/client/auth.dart'; import 'package:commet/client/client.dart'; import 'package:commet/client/matrix/matrix_client.dart'; -import 'package:commet/client/matrix/matrix_mxc_image_provider.dart'; import 'package:commet/config/platform_utils.dart'; import 'package:commet/debug/log.dart'; import 'package:commet/utils/custom_uri.dart'; @@ -30,11 +29,26 @@ class MatrixSSOLoginFlow implements SsoLoginFlow { id: json['id'], name: json['name'], icon: json['icon'] != null - ? MatrixMxcImage(Uri.parse(json['icon']), client.getMatrixClient()) + ? getLoginFlowImage( + Uri.parse( + json['icon'], + ), + client, + ) : null, brand: json['brand'], ); + static NetworkImage getLoginFlowImage(Uri mxc, MatrixClient client) { + var path = + '_matrix/media/v3/thumbnail/${Uri.encodeComponent(mxc.authority)}/${Uri.encodeComponent(mxc.pathSegments.first)}'; + + var server = client.getMatrixClient().baseUri!; + var request = + server.replace(path: path, query: "width=96&height=96&method=crop"); + return NetworkImage(request.toString()); + } + @override Future submit(Client client) async { if (client is! MatrixClient) {