Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSO brand images not loading correctly #374

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading