Skip to content

Commit

Permalink
Fix SSO brand images not loading correctly (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz authored Oct 26, 2024
1 parent f339903 commit 0fc0208
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions commet/lib/client/matrix/auth/matrix_sso_login_flow.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<LoginResult> submit(Client client) async {
if (client is! MatrixClient) {
Expand Down

0 comments on commit 0fc0208

Please sign in to comment.